From 35a7354de1d1cd1bc6a0079f7876ae35fe06038d Mon Sep 17 00:00:00 2001 From: Awiteb Date: Tue, 23 Jul 2024 11:49:55 +0300 Subject: [PATCH] refactor: Use `and_then` instead of `map` Signed-off-by: Awiteb --- crates/oxidetalis_core/src/types/impl_sea_orm.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/crates/oxidetalis_core/src/types/impl_sea_orm.rs b/crates/oxidetalis_core/src/types/impl_sea_orm.rs index c5bc1e4..8d6f7c5 100644 --- a/crates/oxidetalis_core/src/types/impl_sea_orm.rs +++ b/crates/oxidetalis_core/src/types/impl_sea_orm.rs @@ -44,24 +44,20 @@ impl From for Value { impl TryGetable for PublicKey { fn try_get_by(res: &QueryResult, idx: I) -> Result { - ::try_get_by(res, idx) - .map(|v| { - PublicKey::from_str(&v) - .map_err(|err| TryGetError::DbErr(DbErr::Type(err.to_string()))) - }) - .and_then(|res| res) + ::try_get_by(res, idx).and_then(|v| { + PublicKey::from_str(&v).map_err(|err| TryGetError::DbErr(DbErr::Type(err.to_string()))) + }) } } impl ValueType for PublicKey { fn try_from(v: Value) -> Result { ::try_from(v) - .map(|v| PublicKey::from_str(&v).map_err(|_| ValueTypeErr)) - .and_then(|res| res) + .and_then(|v| PublicKey::from_str(&v).map_err(|_| ValueTypeErr)) } fn type_name() -> String { - stringify!(PublicKey).to_owned() + String::from("PublicKey") } fn array_type() -> ArrayType {