diff --git a/pagetop/src/app.rs b/pagetop/src/app.rs index 7426617c..5c6a76a3 100644 --- a/pagetop/src/app.rs +++ b/pagetop/src/app.rs @@ -22,29 +22,7 @@ pub struct Application { impl Application { pub fn prepare(app: ModuleStaticRef) -> Result { // Rótulo de presentación. - if config::SETTINGS.app.startup_banner.to_lowercase() != "off" { - if let Some((term_width, _)) = term_size::dimensions() { - if term_width >= 80 { - let maxlen = (term_width / 10) - 2; - let mut app = config::SETTINGS.app.name.substring(0, maxlen).to_owned(); - if config::SETTINGS.app.name.len() > maxlen { - app = format!("{}...", app); - } - println!( - "\n{} {}\n\n Powered by PageTop {}\n", - figfont::FIGFONT.convert(&app).unwrap(), - &config::SETTINGS.app.description, - env!("CARGO_PKG_VERSION") - ); - } - } - println!( - "\n{}\n{}\n\nPowered by PageTop {}\n", - &config::SETTINGS.app.name, - &config::SETTINGS.app.description, - env!("CARGO_PKG_VERSION") - ); - } + print_on_startup(); // Inicia registro de trazas y eventos. LazyStatic::force(&trace::TRACING); @@ -91,6 +69,33 @@ impl Application { } } +fn print_on_startup() { + if config::SETTINGS.app.startup_banner.to_lowercase() != "off" { + if let Some((term_width, _)) = term_size::dimensions() { + if term_width >= 80 { + let maxlen = (term_width / 10) - 2; + let mut app = config::SETTINGS.app.name.substring(0, maxlen).to_owned(); + if config::SETTINGS.app.name.len() > maxlen { + app = format!("{}...", app); + } + println!( + "\n{} {}\n\n Powered by PageTop {}\n", + figfont::FIGFONT.convert(&app).unwrap(), + &config::SETTINGS.app.description, + env!("CARGO_PKG_VERSION") + ); + return; + } + } + println!( + "\n{}\n{}\n\nPowered by PageTop {}\n", + &config::SETTINGS.app.name, + &config::SETTINGS.app.description, + env!("CARGO_PKG_VERSION") + ); + } +} + async fn service_not_found(request: server::HttpRequest) -> ResultPage { Err(FatalError::NotFound(request)) } diff --git a/pagetop/src/config/de.rs b/pagetop/src/config/de.rs index 79836863..875219af 100644 --- a/pagetop/src/config/de.rs +++ b/pagetop/src/config/de.rs @@ -214,7 +214,7 @@ impl<'de> de::MapAccess<'de> for MapAccess { where K: de::DeserializeSeed<'de>, { - if let Some(&(ref key_s, _)) = self.elements.front() { + if let Some((key_s, _)) = self.elements.front() { let key_de = Value::new(None, key_s as &str); let key = de::DeserializeSeed::deserialize(seed, key_de)?; diff --git a/pagetop/src/config/path.rs b/pagetop/src/config/path.rs index 32599ee7..72376a95 100644 --- a/pagetop/src/config/path.rs +++ b/pagetop/src/config/path.rs @@ -77,8 +77,7 @@ impl Expression { let index = sindex_to_uindex(index, array.len()); if index >= array.len() { - array - .resize((index + 1) as usize, Value::new(None, ValueKind::Nil)); + array.resize(index + 1, Value::new(None, ValueKind::Nil)); } Some(&mut array[index]) @@ -156,7 +155,7 @@ impl Expression { if let ValueKind::Array(ref mut array) = parent.kind { let uindex = sindex_to_uindex(index, array.len()); if uindex >= array.len() { - array.resize((uindex + 1) as usize, Value::new(None, ValueKind::Nil)); + array.resize(uindex + 1, Value::new(None, ValueKind::Nil)); } array[uindex] = value; diff --git a/pagetop/src/config/value.rs b/pagetop/src/config/value.rs index 42929ffa..29d62cfe 100644 --- a/pagetop/src/config/value.rs +++ b/pagetop/src/config/value.rs @@ -7,8 +7,9 @@ use std::fmt; use std::fmt::Display; /// Underlying kind of the configuration value. -#[derive(Debug, Clone, PartialEq)] +#[derive(Clone, Debug, Default, PartialEq)] pub enum ValueKind { + #[default] Nil, Boolean(bool), Integer(i64), @@ -21,12 +22,6 @@ pub enum ValueKind { pub type Array = Vec; pub type Table = HashMap; -impl Default for ValueKind { - fn default() -> Self { - ValueKind::Nil - } -} - impl From> for ValueKind where T: Into, diff --git a/pagetop/src/db/migration/migrator.rs b/pagetop/src/db/migration/migrator.rs index 5ed18f0b..d91cbd7b 100644 --- a/pagetop/src/db/migration/migrator.rs +++ b/pagetop/src/db/migration/migrator.rs @@ -222,6 +222,7 @@ pub trait MigratorTrait: Send { } } +#[allow(clippy::extra_unused_type_parameters)] async fn exec_with_connection<'c, C, F, M>(db: C, f: F) -> Result<(), DbErr> where C: IntoSchemaManagerConnection<'c>,