mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-11-26 13:31:02 +00:00
Implement OneOrMany<&AnyString>::as_as_str()
This commit is contained in:
parent
a6a21d5dfa
commit
f0112850fa
1 changed files with 9 additions and 0 deletions
|
@ -435,6 +435,15 @@ impl AsAsStr for &AnyString {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsAsStr for OneOrMany<&AnyString> {
|
||||
fn as_as_str(&self) -> Option<&str> {
|
||||
self.as_one().and_then(|prop| prop.as_as_str()).or_else(|| {
|
||||
self.as_many()
|
||||
.and_then(|props| props.iter().next().and_then(|prop| prop.as_as_str()))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
Loading…
Reference in a new issue