Implement &AnyString::as_as_str()

This commit is contained in:
Kitaiti Makoto 2022-02-13 00:59:15 +09:00
parent 3db10a09bb
commit 28643fc2c2

View File

@ -429,6 +429,17 @@ impl ToAsString for OneOrMany<&AnyString> {
} }
} }
trait AsAsStr {
fn as_as_str(&self) -> Option<&str>;
}
impl AsAsStr for &AnyString {
fn as_as_str(&self) -> Option<&str> {
self.as_xsd_string()
.or_else(|| self.as_rdf_lang_string().map(|ls| ls.value.as_str()))
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;