♻️ Código revisado con cargo fmt/clippy

This commit is contained in:
Manuel Cillero 2023-05-14 21:10:47 +02:00
parent 1d82c59c3d
commit 9bb429acf0
5 changed files with 34 additions and 34 deletions

View file

@ -22,29 +22,7 @@ pub struct Application {
impl Application {
pub fn prepare(app: ModuleStaticRef) -> Result<Self, Error> {
// 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<Markup, FatalError> {
Err(FatalError::NotFound(request))
}

View file

@ -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)?;

View file

@ -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;

View file

@ -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<Value>;
pub type Table = HashMap<String, Value>;
impl Default for ValueKind {
fn default() -> Self {
ValueKind::Nil
}
}
impl<T> From<Option<T>> for ValueKind
where
T: Into<ValueKind>,

View file

@ -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>,