I am currently using Sophia to parse a file type. I need to match
against a Sophia Term
object.
or more specificially against the IriData variant.
Currently I am doing this with a very clunky use of a
match
. Something like this:
match t {
Term::Iri(iri) if iri == "http://www.w3.org/2002/07/owl#AllValuesFrom" => {todo!()},
Term::Iri(iri) if iri == "http://www.w3.org/2002/07/owl#AnnotatedSource" => {todo!()},
}
As far as I can tell, I cannot do anything better than this with a
match
statement, because of equality check has to be done in a
pattern guard.
So, I thought, I need a hash-table look up instead -- I could use the
IriData
as a key and return a Unit enum instance that will be easier
to handle.
But this fails for me, because IriData
has only crate private
methods for creating instances. So I cannot see a way to look a hash
map with IriData
keys.
Am I missing a trick here?