a bit of clippy

This commit is contained in:
2023-09-11 19:47:51 +02:00
parent 008076f6df
commit 205eae2264
6 changed files with 18 additions and 21 deletions

View File

@@ -73,8 +73,8 @@ impl<'a> AuthError {
pub fn to_prom_labels(&'a self) -> Vec<(&'static str, String)> {
match self {
Self::AuthenticationUserNotFound { username } => vec![("username", username.clone())],
Self::AuthenticationHeaderMissing => vec![],
Self::AuthenticationHeaderInvalid { message: _ } => vec![],
Self::AuthenticationHeaderMissing
| Self::AuthenticationHeaderInvalid { message: _ } => vec![],
}
}
}

View File

@@ -51,7 +51,7 @@ where
Ok(None)
} else {
Ok(Some(Uuid::try_from(value).map_err(|e| {
E::custom(format!("UUID parsing failed: {}", e))
E::custom(format!("UUID parsing failed: {e}"))
})?))
}
}

View File

@@ -69,7 +69,7 @@ trait Forwarder {
fn build(
config: Self::Config,
shutdown_functions: &mut Vec<Box<dyn FnOnce() -> Result<(), Box<dyn std::error::Error>>>>,
shutdown_functions: &mut Vec<ShutdownFunction>,
) -> Option<Box<dyn tracing_subscriber::Layer<dyn tracing::Subscriber>>>;
}
@@ -77,8 +77,8 @@ trait Forwarder {
fn get_jaeger_layer<
T: tracing::Subscriber + for<'a> tracing_subscriber::registry::LookupSpan<'a>,
>(
config: OpenTelemetryConfig,
shutdown_functions: &mut Vec<Box<dyn FnOnce() -> Result<(), Box<dyn std::error::Error>>>>,
config: &OpenTelemetryConfig,
shutdown_functions: &mut Vec<ShutdownFunction>,
) -> Option<impl tracing_subscriber::Layer<T>> {
match config {
OpenTelemetryConfig::Enabled => {
@@ -119,6 +119,8 @@ fn get_jaeger_layer<
}
}
type ShutdownFunction = Box<dyn FnOnce() -> Result<(), Box<dyn std::error::Error>>>;
pub async fn init<Func, T>(
#[cfg(feature = "jaeger")] opentelemetry_config: OpenTelemetryConfig,
#[cfg(feature = "tokio-console")] tokio_console_config: TokioConsoleConfig,
@@ -132,13 +134,10 @@ where
// mut is dependent on features (it's only required when jaeger is set), so
// let's just disable the lint
#[cfg(feature = "jaeger")]
let mut shutdown_functions: Vec<
Box<dyn FnOnce() -> Result<(), Box<dyn std::error::Error>>>,
> = vec![];
let mut shutdown_functions: Vec<ShutdownFunction> = vec![];
#[cfg(not(feature = "jaeger"))]
let shutdown_functions: Vec<Box<dyn FnOnce() -> Result<(), Box<dyn std::error::Error>>>> =
vec![];
let shutdown_functions: Vec<ShutdownFunction> = vec![];
#[cfg(feature = "tokio-console")]
let console_layer = match tokio_console_config {
@@ -149,7 +148,7 @@ where
let stdout_layer = get_stdout_layer();
#[cfg(feature = "jaeger")]
let jaeger_layer = get_jaeger_layer(opentelemetry_config, &mut shutdown_functions);
let jaeger_layer = get_jaeger_layer(&opentelemetry_config, &mut shutdown_functions);
let registry = Registry::default();

View File

@@ -23,7 +23,7 @@ pub enum HtmxAction {
impl fmt::Display for HtmxAction {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::Get(path) => write!(f, "{}", path),
Self::Get(path) => write!(f, "{path}"),
}
}
}
@@ -36,7 +36,7 @@ pub enum FallbackAction {
impl fmt::Display for FallbackAction {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::Get(path) => write!(f, "{}", path),
Self::Get(path) => write!(f, "{path}"),
}
}
}
@@ -66,9 +66,7 @@ impl ComponentId {
let id = &id[..9];
// URL_SAFE because we cannot have slashes in the output
let id = base64::engine::general_purpose::URL_SAFE.encode(id);
id
base64::engine::general_purpose::URL_SAFE.encode(id)
}
}

View File

@@ -161,7 +161,7 @@ impl<'a> Component for Body<'a> {
item: TopLevelPage::Inventory,
active_page: self.args.active_page
}
).build(&context)
).build(context)
)
(
HeaderLink::init(
@@ -170,7 +170,7 @@ impl<'a> Component for Body<'a> {
item: TopLevelPage::Trips,
active_page: self.args.active_page
}
).build(&context)
).build(context)
)
}
a
@@ -210,7 +210,7 @@ impl Root {
(Body::init(Parent::Root, BodyArgs {
body,
active_page
}).build(&context))
}).build(context))
}
)
}

View File

@@ -126,7 +126,7 @@ pub struct NewTrip;
impl NewTrip {
#[tracing::instrument(skip(trips))]
pub fn build(trips: &Vec<models::trips::Trip>) -> Markup {
pub fn build(trips: &[models::trips::Trip]) -> Markup {
html!(
form
name="new_trip"