[REFACTORING]Use method chain instead of if clauses
This commit is contained in:
@@ -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()))
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user