mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-12-23 18:40:34 +00:00
[REFACTORING]Reduce duplicated closure
This commit is contained in:
parent
d3e11c78d7
commit
c1b9ebdae6
1 changed files with 4 additions and 7 deletions
|
@ -446,15 +446,12 @@ pub trait ToAsUri {
|
|||
impl ToAsUri for OneOrMany<AnyBase> {
|
||||
fn to_as_uri(&self) -> Option<String> {
|
||||
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(|| {
|
||||
self.as_many().and_then(|props| {
|
||||
props
|
||||
.iter()
|
||||
.next()
|
||||
.and_then(|prop| prop.as_xsd_any_uri().map(|uri| uri.to_string()))
|
||||
})
|
||||
self.as_many()
|
||||
.and_then(|props| props.iter().next().and_then(|prop| prop.as_xsd_any_uri()))
|
||||
})
|
||||
.map(|uri| uri.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue