From c10c06ec1dc1fcd8701c28b1aca5c4ba0d2668a9 Mon Sep 17 00:00:00 2001 From: Mikhail Katychev Date: Mon, 7 Oct 2024 10:22:59 -0500 Subject: [PATCH] updated mownstr --- Cargo.toml | 2 +- api/src/term/_native_iri.rs | 4 ++-- api/src/term/_native_literal.rs | 12 +++++------ api/src/term/_simple.rs | 36 ++++++++++++++++----------------- api/src/term/bnode_id.rs | 2 +- api/src/term/var_name.rs | 2 +- jsonld/src/parser/adapter.rs | 4 ++-- jsonld/src/vocabulary.rs | 2 +- term/src/_generic.rs | 6 +++--- term/src/_macro.rs | 6 +++--- 10 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 53dd08b6..d7753fb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,7 +44,7 @@ env_logger = "0.11.3" futures-util = "0.3.28" lazy_static = "1.4.0" log = "0.4.21" -mownstr = "0.2.1" +mownstr = "0.3.0" oxiri = "0.2.2" regex = "1.6.0" resiter = "0.5.0" diff --git a/api/src/term/_native_iri.rs b/api/src/term/_native_iri.rs index 1f811d98..79bf2205 100644 --- a/api/src/term/_native_iri.rs +++ b/api/src/term/_native_iri.rs @@ -13,7 +13,7 @@ where TermKind::Iri } fn iri(&self) -> Option>> { - Some(IriRef::new_unchecked(MownStr::from_str(self.as_str()))) + Some(IriRef::new_unchecked(MownStr::from_ref(self.as_str()))) } fn borrow_term(&self) -> Self::BorrowTerm<'_> { self @@ -30,7 +30,7 @@ where TermKind::Iri } fn iri(&self) -> Option>> { - Some(IriRef::new_unchecked(MownStr::from_str(self.as_str()))) + Some(IriRef::new_unchecked(MownStr::from_ref(self.as_str()))) } fn borrow_term(&self) -> Self::BorrowTerm<'_> { self diff --git a/api/src/term/_native_literal.rs b/api/src/term/_native_literal.rs index 1b301cee..2ff4ff82 100644 --- a/api/src/term/_native_literal.rs +++ b/api/src/term/_native_literal.rs @@ -34,7 +34,7 @@ impl Term for f64 { Some(MownStr::from(format!("{}", self))) } fn datatype(&self) -> Option> { - Some(IriRef::new_unchecked(MownStr::from_str(&XSD_DOUBLE))) + Some(IriRef::new_unchecked(MownStr::from_ref(&XSD_DOUBLE))) } fn language_tag(&self) -> Option> { None @@ -70,7 +70,7 @@ impl Term for i32 { Some(MownStr::from(format!("{}", self))) } fn datatype(&self) -> Option> { - Some(IriRef::new_unchecked(MownStr::from_str(&XSD_INTEGER))) + Some(IriRef::new_unchecked(MownStr::from_ref(&XSD_INTEGER))) } fn language_tag(&self) -> Option> { None @@ -107,7 +107,7 @@ impl Term for isize { Some(MownStr::from(format!("{}", self))) } fn datatype(&self) -> Option> { - Some(IriRef::new_unchecked(MownStr::from_str(&XSD_INTEGER))) + Some(IriRef::new_unchecked(MownStr::from_ref(&XSD_INTEGER))) } fn language_tag(&self) -> Option> { None @@ -144,7 +144,7 @@ impl Term for usize { Some(MownStr::from(format!("{}", self))) } fn datatype(&self) -> Option> { - Some(IriRef::new_unchecked(MownStr::from_str(&XSD_INTEGER))) + Some(IriRef::new_unchecked(MownStr::from_ref(&XSD_INTEGER))) } fn language_tag(&self) -> Option> { None @@ -180,7 +180,7 @@ impl Term for str { Some(MownStr::from(self)) } fn datatype(&self) -> Option> { - Some(IriRef::new_unchecked(MownStr::from_str(&XSD_STRING))) + Some(IriRef::new_unchecked(MownStr::from_ref(&XSD_STRING))) } fn language_tag(&self) -> Option> { None @@ -216,7 +216,7 @@ impl Term for bool { Some(MownStr::from(if *self { "true" } else { "false" })) } fn datatype(&self) -> Option> { - Some(IriRef::new_unchecked(MownStr::from_str(&XSD_BOOLEAN))) + Some(IriRef::new_unchecked(MownStr::from_ref(&XSD_BOOLEAN))) } fn language_tag(&self) -> Option> { None diff --git a/api/src/term/_simple.rs b/api/src/term/_simple.rs index eae7034d..c30ce263 100644 --- a/api/src/term/_simple.rs +++ b/api/src/term/_simple.rs @@ -59,20 +59,20 @@ impl<'a> Term for SimpleTerm<'a> { fn datatype(&self) -> Option> { match self { LiteralDatatype(_, iri) => Some(IriRef::new_unchecked(iri.borrowed())), - LiteralLanguage(..) => Some(IriRef::new_unchecked(MownStr::from_str(&RDF_LANG_STRING))), + LiteralLanguage(..) => Some(IriRef::new_unchecked(MownStr::from_ref(&RDF_LANG_STRING))), _ => None, } } fn language_tag(&self) -> Option> { if let LiteralLanguage(_, tag) = self { - Some(LanguageTag::new_unchecked(MownStr::from_str(tag))) + Some(LanguageTag::new_unchecked(MownStr::from_ref(tag))) } else { None } } fn variable(&self) -> Option> { if let Variable(name) = self { - Some(VarName::new_unchecked(MownStr::from_str(name))) + Some(VarName::new_unchecked(MownStr::from_ref(name))) } else { None } @@ -224,7 +224,7 @@ mod test { #[test] fn iri_from_scratch() { - let value = IriRef::new_unchecked(MownStr::from_str("http://example.org/")); + let value = IriRef::new_unchecked(MownStr::from_ref("http://example.org/")); let t = SimpleTerm::Iri(value.clone()); assert_consistent_term_impl(&t); assert_eq!(t.borrow_term(), &t); @@ -234,7 +234,7 @@ mod test { #[test] fn bnode_from_scratch() { - let value = BnodeId::new_unchecked(MownStr::from_str("b1")); + let value = BnodeId::new_unchecked(MownStr::from_ref("b1")); let t = SimpleTerm::BlankNode(value.clone()); assert_consistent_term_impl(&t); assert_eq!(t.borrow_term(), &t); @@ -244,8 +244,8 @@ mod test { #[test] fn literal_dt_from_scratch() { - let value = MownStr::from_str("hello world"); - let datatype = IriRef::new_unchecked(MownStr::from_str("http://example.org/")); + let value = MownStr::from_ref("hello world"); + let datatype = IriRef::new_unchecked(MownStr::from_ref("http://example.org/")); let t = SimpleTerm::LiteralDatatype(value.clone(), datatype.clone()); assert_consistent_term_impl(&t); assert_eq!(t.borrow_term(), &t); @@ -256,8 +256,8 @@ mod test { #[test] fn literal_lang_from_scratch() { - let value = MownStr::from_str("hello world"); - let tag = LanguageTag::new_unchecked(MownStr::from_str("en-US")); + let value = MownStr::from_ref("hello world"); + let tag = LanguageTag::new_unchecked(MownStr::from_ref("en-US")); let t = SimpleTerm::LiteralLanguage(value.clone(), tag.clone()); assert_consistent_term_impl(&t); assert_eq!(t.borrow_term(), &t); @@ -268,7 +268,7 @@ mod test { #[test] fn variable_from_scratch() { - let value = VarName::new_unchecked(MownStr::from_str("x")); + let value = VarName::new_unchecked(MownStr::from_ref("x")); let t = SimpleTerm::Variable(value.clone()); assert_consistent_term_impl(&t); assert_eq!(t.borrow_term(), &t); @@ -278,8 +278,8 @@ mod test { #[test] fn triple_from_scratch() { - let s: SimpleTerm<'_> = BnodeId::new_unchecked(MownStr::from_str("s")).into_term(); - let p: SimpleTerm<'_> = IriRef::new_unchecked(MownStr::from_str("p")).into_term(); + let s: SimpleTerm<'_> = BnodeId::new_unchecked(MownStr::from_ref("s")).into_term(); + let p: SimpleTerm<'_> = IriRef::new_unchecked(MownStr::from_ref("p")).into_term(); let o: SimpleTerm<'_> = "o".into_term(); let spo = [s.clone(), p.clone(), o.clone()]; let t = SimpleTerm::Triple(Box::new(spo.clone())); @@ -302,8 +302,8 @@ mod test { #[test] fn nested_triple_from_scratch() { - let s1: SimpleTerm<'_> = BnodeId::new_unchecked(MownStr::from_str("s")).into_term(); - let p1: SimpleTerm<'_> = IriRef::new_unchecked(MownStr::from_str("p")).into_term(); + let s1: SimpleTerm<'_> = BnodeId::new_unchecked(MownStr::from_ref("s")).into_term(); + let p1: SimpleTerm<'_> = IriRef::new_unchecked(MownStr::from_ref("p")).into_term(); let o1: SimpleTerm<'_> = "o".into_term(); let spo1 = [s1.clone(), p1.clone(), o1.clone()]; let t1 = SimpleTerm::Triple(Box::new(spo1)); @@ -366,8 +366,8 @@ mod test { #[test] fn triple_from_term() { - let s: SimpleTerm<'_> = BnodeId::new_unchecked(MownStr::from_str("s")).into_term(); - let p: SimpleTerm<'_> = IriRef::new_unchecked(MownStr::from_str("p")).into_term(); + let s: SimpleTerm<'_> = BnodeId::new_unchecked(MownStr::from_ref("s")).into_term(); + let p: SimpleTerm<'_> = IriRef::new_unchecked(MownStr::from_ref("p")).into_term(); let o: SimpleTerm<'_> = "o".into_term(); let spo = [s.clone(), p.clone(), o.clone()]; let tr = SimpleTerm::from_triple(spo.spo()); @@ -439,8 +439,8 @@ mod test { #[test] fn triple_from_term_ref() { - let s: SimpleTerm<'_> = BnodeId::new_unchecked(MownStr::from_str("s")).into_term(); - let p: SimpleTerm<'_> = IriRef::new_unchecked(MownStr::from_str("p")).into_term(); + let s: SimpleTerm<'_> = BnodeId::new_unchecked(MownStr::from_ref("s")).into_term(); + let p: SimpleTerm<'_> = IriRef::new_unchecked(MownStr::from_ref("p")).into_term(); let o: SimpleTerm<'_> = "o".into_term(); let spo = [s.clone(), p.clone(), o.clone()]; let tr = SimpleTerm::from_triple(spo.spo()); diff --git a/api/src/term/bnode_id.rs b/api/src/term/bnode_id.rs index d589fd13..32b25fcb 100644 --- a/api/src/term/bnode_id.rs +++ b/api/src/term/bnode_id.rs @@ -67,7 +67,7 @@ where TermKind::BlankNode } fn bnode_id(&self) -> Option> { - Some(self.as_ref().map_unchecked(MownStr::from_str)) + Some(self.as_ref().map_unchecked(MownStr::from_ref)) } fn borrow_term(&self) -> Self::BorrowTerm<'_> { self diff --git a/api/src/term/var_name.rs b/api/src/term/var_name.rs index d2a680b5..1a9c18c1 100644 --- a/api/src/term/var_name.rs +++ b/api/src/term/var_name.rs @@ -56,7 +56,7 @@ where TermKind::Variable } fn variable(&self) -> Option> { - Some(self.as_ref().map_unchecked(MownStr::from_str)) + Some(self.as_ref().map_unchecked(MownStr::from_ref)) } fn borrow_term(&self) -> Self::BorrowTerm<'_> { self diff --git a/jsonld/src/parser/adapter.rs b/jsonld/src/parser/adapter.rs index 45c78564..4c87e9f3 100644 --- a/jsonld/src/parser/adapter.rs +++ b/jsonld/src/parser/adapter.rs @@ -43,7 +43,7 @@ impl SophiaTerm for RdfTerm { fn lexical_form(&self) -> Option { match &self.0 { - Term::Literal(lit) => Some(MownStr::from_str(lit.value())), + Term::Literal(lit) => Some(MownStr::from_ref(lit.value())), _ => None, } } @@ -61,7 +61,7 @@ impl SophiaTerm for RdfTerm { fn language_tag(&self) -> Option> { match &self.0 { Term::Literal(lit) => match lit.type_() { - Type::LangString(tag) => Some(tag.as_ref().map_unchecked(MownStr::from_str)), + Type::LangString(tag) => Some(tag.as_ref().map_unchecked(MownStr::from_ref)), Type::Any(_) => None, }, _ => None, diff --git a/jsonld/src/vocabulary.rs b/jsonld/src/vocabulary.rs index 39f5e38f..1f0860a2 100644 --- a/jsonld/src/vocabulary.rs +++ b/jsonld/src/vocabulary.rs @@ -140,6 +140,6 @@ impl Term for ArcBnode { } fn bnode_id(&self) -> Option> { - Some(BnodeId::new_unchecked(MownStr::from_str(&self[2..]))) + Some(BnodeId::new_unchecked(MownStr::from_ref(&self[2..]))) } } diff --git a/term/src/_generic.rs b/term/src/_generic.rs index 834abe58..b400b0ce 100644 --- a/term/src/_generic.rs +++ b/term/src/_generic.rs @@ -59,16 +59,16 @@ impl + Debug> Term for GenericLiteral { } fn lexical_form(&self) -> Option { - Some(MownStr::from_str(self.get_lexical_form())) + Some(MownStr::from_ref(self.get_lexical_form())) } fn datatype(&self) -> Option> { - Some(self.get_datatype().map_unchecked(MownStr::from_str)) + Some(self.get_datatype().map_unchecked(MownStr::from_ref)) } fn language_tag(&self) -> Option> { self.get_language_tag() - .map(|tag| tag.map_unchecked(MownStr::from_str)) + .map(|tag| tag.map_unchecked(MownStr::from_ref)) } } diff --git a/term/src/_macro.rs b/term/src/_macro.rs index 6a7d27bb..4c54b471 100644 --- a/term/src/_macro.rs +++ b/term/src/_macro.rs @@ -72,7 +72,7 @@ macro_rules! gen_term { fn iri(&self) -> Option> { if let $type_name::Iri(iri) = self { - Some(iri.as_ref().map_unchecked(MownStr::from_str)) + Some(iri.as_ref().map_unchecked(MownStr::from_ref)) } else { None } @@ -80,7 +80,7 @@ macro_rules! gen_term { fn bnode_id(&self) -> Option> { if let $type_name::BlankNode(id) = self { - Some(id.as_ref().map_unchecked(MownStr::from_str)) + Some(id.as_ref().map_unchecked(MownStr::from_ref)) } else { None } @@ -112,7 +112,7 @@ macro_rules! gen_term { fn variable(&self) -> Option> { if let $type_name::Variable(name) = self { - Some(name.as_ref().map_unchecked(MownStr::from_str)) + Some(name.as_ref().map_unchecked(MownStr::from_ref)) } else { None }