🧑‍💻 Passes fmt and clippy checks

This commit is contained in:
Manuel Cillero 2023-10-26 21:10:37 +02:00
parent 3dac2c4a73
commit 54d216437a
3 changed files with 14 additions and 24 deletions

View file

@ -112,7 +112,7 @@ pub fn run_migrations() {
if let Some(dbconn) = &*DBCONN {
use crate::locale::L10n;
match run_now({
if let Err(e) = run_now({
struct Migrator;
impl MigratorTrait for Migrator {
fn migrations() -> Vec<MigrationItem> {
@ -125,15 +125,12 @@ pub fn run_migrations() {
}
Migrator::up(SchemaManagerConnection::Connection(dbconn), None)
}) {
Err(e) => {
L10n::l("db_migration_fail")
.with_arg("dberr", format!("{}", e))
.error();
}
_ => {}
L10n::l("db_migration_fail")
.with_arg("dberr", format!("{}", e))
.error();
};
match run_now({
if let Err(e) = run_now({
struct Migrator;
impl MigratorTrait for Migrator {
fn migrations() -> Vec<MigrationItem> {
@ -146,12 +143,9 @@ pub fn run_migrations() {
}
Migrator::down(SchemaManagerConnection::Connection(dbconn), None)
}) {
Err(e) => {
L10n::l("db_migration_fail")
.with_arg("dberr", format!("{}", e))
.error();
}
_ => {}
L10n::l("db_migration_fail")
.with_arg("dberr", format!("{}", e))
.error();
};
}
}

View file

@ -70,7 +70,7 @@ pub(crate) static DBCONN: LazyStatic<Option<DbConn>> = LazyStatic::new(|| {
db_opt.max_connections(config::SETTINGS.database.max_pool_size);
db_opt
}))
.expect(L10n::l("db_connection_fail").to_string().as_str()),
.unwrap_or_else(|_| panic!("{}", L10n::l("db_connection_fail").to_string())),
)
} else {
None

View file

@ -112,17 +112,13 @@ static LANGUAGES: LazyStatic<HashMap<String, (LanguageIdentifier, &str)>> = Lazy
]
});
static FALLBACK_LANGID: LazyStatic<LanguageIdentifier> = LazyStatic::new(|| langid!("en-US"));
pub fn langid_fallback() -> &'static LanguageIdentifier {
&FALLBACK_LANGID
}
pub static LANGID_FALLBACK: LazyStatic<LanguageIdentifier> = LazyStatic::new(|| langid!("en-US"));
/// Almacena el Identificador de Idioma Unicode
/// ([Unicode Language Identifier](https://unicode.org/reports/tr35/tr35.html#Unicode_language_identifier))
/// global para la aplicación a partir de `SETTINGS.app.language`.
pub(crate) static LANGID: LazyStatic<&LanguageIdentifier> = LazyStatic::new(|| {
langid_for(config::SETTINGS.app.language.as_str()).unwrap_or(langid_fallback())
pub static LANGID: LazyStatic<&LanguageIdentifier> = LazyStatic::new(|| {
langid_for(config::SETTINGS.app.language.as_str()).unwrap_or(&LANGID_FALLBACK)
});
pub fn langid_for(language: impl Into<String>) -> Result<&'static LanguageIdentifier, String> {
@ -131,7 +127,7 @@ pub fn langid_for(language: impl Into<String>) -> Result<&'static LanguageIdenti
Some((langid, _)) => Ok(langid),
None => {
if language.is_empty() {
Ok(&FALLBACK_LANGID)
Ok(&LANGID_FALLBACK)
} else {
Err(L10n::l(LANGUAGE_SET_FAILURE)
.with_arg("language", config::SETTINGS.app.language.as_str())
@ -284,7 +280,7 @@ impl ToString for L10n {
Some(locales) => locales
.lookup_with_args(
match key.as_str() {
LANGUAGE_SET_FAILURE => &FALLBACK_LANGID,
LANGUAGE_SET_FAILURE => &LANGID_FALLBACK,
_ => &LANGID,
},
key,