Merge pull request #28 from pchampin/destruct

add destruct method to Literal and Quad
pull/35/head
Thomas Tanon 5 years ago committed by GitHub
commit cc76ae8298
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      lib/src/model/literal.rs
  2. 5
      lib/src/model/triple.rs

@ -133,6 +133,17 @@ impl Literal {
_ => false,
}
}
/// Extract components from this literal
pub fn destruct(self) -> (String, Option<NamedNode>, Option<String>) {
match self.0 {
LiteralContent::String(s) => (s, None, None),
LiteralContent::LanguageTaggedString { value, language } => {
(value, None, Some(language))
}
LiteralContent::TypedLiteral { value, datatype } => (value, Some(datatype), None),
}
}
}
impl fmt::Display for Literal {

@ -287,6 +287,11 @@ impl Quad {
pub fn into_triple(self) -> Triple {
Triple::new(self.subject, self.predicate, self.object)
}
/// Extract components from this quad
pub fn destruct(self) -> (NamedOrBlankNode, NamedNode, Term, Option<NamedOrBlankNode>) {
(self.subject, self.predicate, self.object, self.graph_name)
}
}
impl fmt::Display for Quad {

Loading…
Cancel
Save