From 6cabf6da15b7e03e104be69ee7e2f0a32e9a79f6 Mon Sep 17 00:00:00 2001 From: Tpt Date: Sat, 21 Jan 2023 21:29:05 +0100 Subject: [PATCH] Oxrdf: adds NamedOrBlankNode to GraphName conversion functions --- lib/oxrdf/src/triple.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/oxrdf/src/triple.rs b/lib/oxrdf/src/triple.rs index 4006c8fa..4502bc5a 100644 --- a/lib/oxrdf/src/triple.rs +++ b/lib/oxrdf/src/triple.rs @@ -921,6 +921,23 @@ impl From> for GraphName { } } +impl From for GraphName { + #[inline] + fn from(node: NamedOrBlankNode) -> Self { + match node { + NamedOrBlankNode::NamedNode(node) => node.into(), + NamedOrBlankNode::BlankNode(node) => node.into(), + } + } +} + +impl From> for GraphName { + #[inline] + fn from(node: NamedOrBlankNodeRef<'_>) -> Self { + node.into_owned().into() + } +} + /// A possible borrowed graph name. /// It is the union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri), [blank nodes](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node), and the [default graph name](https://www.w3.org/TR/rdf11-concepts/#dfn-default-graph). #[derive(Eq, PartialEq, Debug, Clone, Copy, Hash)] @@ -995,6 +1012,23 @@ impl<'a> From<&'a BlankNode> for GraphNameRef<'a> { } } +impl<'a> From> for GraphNameRef<'a> { + #[inline] + fn from(node: NamedOrBlankNodeRef<'a>) -> Self { + match node { + NamedOrBlankNodeRef::NamedNode(node) => node.into(), + NamedOrBlankNodeRef::BlankNode(node) => node.into(), + } + } +} + +impl<'a> From<&'a NamedOrBlankNode> for GraphNameRef<'a> { + #[inline] + fn from(node: &'a NamedOrBlankNode) -> Self { + node.as_ref().into() + } +} + impl<'a> From<&'a GraphName> for GraphNameRef<'a> { #[inline] fn from(node: &'a GraphName) -> Self {