diff --git a/src/api/icons.rs b/src/api/icons.rs index 33849bbb..b7674f3a 100644 --- a/src/api/icons.rs +++ b/src/api/icons.rs @@ -354,8 +354,8 @@ struct Icon { impl Icon { const fn new(priority: u8, href: String) -> Self { Self { - href, priority, + href, } } } diff --git a/src/db/mod.rs b/src/db/mod.rs index ba922427..eca0c956 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -157,6 +157,24 @@ pub trait FromDb { fn from_db(self) -> Self::Output; } +impl FromDb for Vec { + type Output = Vec; + #[allow(clippy::wrong_self_convention)] + #[inline(always)] + fn from_db(self) -> Self::Output { + self.into_iter().map(crate::db::FromDb::from_db).collect() + } +} + +impl FromDb for Option { + type Output = Option; + #[allow(clippy::wrong_self_convention)] + #[inline(always)] + fn from_db(self) -> Self::Output { + self.map(crate::db::FromDb::from_db) + } +} + // For each struct eg. Cipher, we create a CipherDb inside a module named __$db_model (where $db is sqlite, mysql or postgresql), // to implement the Diesel traits. We also provide methods to convert between them and the basic structs. Later, that module will be auto imported when using db_run! #[macro_export] @@ -197,18 +215,9 @@ macro_rules! db_object { impl crate::db::FromDb for [<$name Db>] { type Output = super::$name; + #[allow(clippy::wrong_self_convention)] #[inline(always)] fn from_db(self) -> Self::Output { super::$name { $( $field: self.$field, )+ } } } - - impl crate::db::FromDb for Vec<[<$name Db>]> { - type Output = Vec; - #[inline(always)] fn from_db(self) -> Self::Output { self.into_iter().map(crate::db::FromDb::from_db).collect() } - } - - impl crate::db::FromDb for Option<[<$name Db>]> { - type Output = Option; - #[inline(always)] fn from_db(self) -> Self::Output { self.map(crate::db::FromDb::from_db) } - } } }; }