From a1a7acfe941ed11fa3968fcd75ff8bced1352142 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Mon, 14 Feb 2022 20:44:28 +0900 Subject: [PATCH] Use new activitystreams APIs --- plume-common/src/activity_pub/mod.rs | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/plume-common/src/activity_pub/mod.rs b/plume-common/src/activity_pub/mod.rs index b7ebae31..2a8e91a6 100644 --- a/plume-common/src/activity_pub/mod.rs +++ b/plume-common/src/activity_pub/mod.rs @@ -423,19 +423,9 @@ 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())) - } -} - 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())) - }) + self.iter().next().map(|prop| prop.as_str()) } } @@ -445,13 +435,9 @@ pub trait ToAsUri { impl ToAsUri for OneOrMany { fn to_as_uri(&self) -> Option { - self.as_one() - .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.iter() + .next() + .and_then(|prop| prop.as_xsd_any_uri().map(|uri| uri.to_string())) } }