[REFACTORING]Reduce duplicated closure
This commit is contained in:
parent
d3e11c78d7
commit
c1b9ebdae6
@ -446,15 +446,12 @@ pub trait ToAsUri {
|
|||||||
impl ToAsUri for OneOrMany<AnyBase> {
|
impl ToAsUri for OneOrMany<AnyBase> {
|
||||||
fn to_as_uri(&self) -> Option<String> {
|
fn to_as_uri(&self) -> Option<String> {
|
||||||
self.as_one()
|
self.as_one()
|
||||||
.and_then(|prop| prop.as_xsd_any_uri().map(|uri| uri.to_string()))
|
.and_then(|prop| prop.as_xsd_any_uri())
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
self.as_many().and_then(|props| {
|
self.as_many()
|
||||||
props
|
.and_then(|props| props.iter().next().and_then(|prop| prop.as_xsd_any_uri()))
|
||||||
.iter()
|
|
||||||
.next()
|
|
||||||
.and_then(|prop| prop.as_xsd_any_uri().map(|uri| uri.to_string()))
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
.map(|uri| uri.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user