Getting a owned IriRef<MownStr>> from a SimpleTerm #167
Unanswered
GordianDziwis
asked this question in
Q&A
Replies: 1 comment
-
You could remove some ugliness by using let dt = match datatype.as_ref() {
Some(dt_inner) => dt_inner
.try_as_term(diagram)?
.iri()
.unwrap()
.map_unchecked(|txt| txt.to_string().into()),
None => xsd::string.iri().unwrap(),
};
SimpleTerm::LiteralDatatype(lexical_form.as_str().into(), dt) Assuming you have control over the type of let dt = match datatype.as_ref() {
Some(dt_inner) => dt_inner.try_as_iri(diagram)?,
None => xsd::string.iri().unwrap(),
};
SimpleTerm::LiteralDatatype(lexical_form.as_str().into(), dt) where the return type of NB: if you don't have control over the type of |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am currently converting my codebase to sophia 0.8.0. And I have some ugliness I want to get rid of. In the
Some(dt_inner)
match arm, I need an ownedIriRef<MownStr>>
from aSimpleTerm
, which gets complicated becauseiri()
takes a reference to self ofsimple_term
which goes out of scope after the closure.My workaround is:
Is there a nicer way to do this?
Beta Was this translation helpful? Give feedback.
All reactions