[REFACTORING]Use method chain instead of if clauses
This commit is contained in:
parent
4ccfec8019
commit
d3e11c78d7
@ -445,16 +445,16 @@ pub trait ToAsUri {
|
||||
|
||||
impl ToAsUri for OneOrMany<AnyBase> {
|
||||
fn to_as_uri(&self) -> Option<String> {
|
||||
if let Some(prop) = self.as_one() {
|
||||
prop.as_xsd_any_uri().map(|uri| uri.to_string())
|
||||
} else if let Some(prop) = self.as_many() {
|
||||
prop.iter()
|
||||
.next()
|
||||
.and_then(|p| p.as_xsd_any_uri())
|
||||
.map(|uri| uri.to_string())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
self.as_one()
|
||||
.and_then(|prop| prop.as_xsd_any_uri().map(|uri| uri.to_string()))
|
||||
.or_else(|| {
|
||||
self.as_many().and_then(|props| {
|
||||
props
|
||||
.iter()
|
||||
.next()
|
||||
.and_then(|prop| prop.as_xsd_any_uri().map(|uri| uri.to_string()))
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1074,11 +1074,7 @@ impl FromId07<DbConn> for User {
|
||||
..NewUser::default()
|
||||
};
|
||||
|
||||
let avatar_id = if let Some(icon) = acct.object_ref().icon() {
|
||||
icon.to_as_uri()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let avatar_id = acct.object_ref().icon().and_then(|icon| icon.to_as_uri());
|
||||
|
||||
let (ap_url, inst) = {
|
||||
let any_base = acct.into_any_base()?;
|
||||
|
Loading…
Reference in New Issue
Block a user