Closed MattesWhite closed 3 years ago
Yes, indeed I have a requirement for something to create new RDF terms, e.g. when I turn the results of the RDF test suite into RDF itself or more generally try to do some object-triple-mapping.
Another use case is creating new blank nodes when parsing []
terms in Turtle. But that can be handled by a dedicated crate.
TermFactory
Given the new TTerm
trait, it is right to go for a Term
agnostic factory, especially agnostic of TermData
. However, I'd rather stick with the factory pattern.
The thing with a factory is that we still have a dedicated entity. The CreateableTerm
solution you proposed has only static
methods (no self
argument). This makes it quite difficult to implement the trait for a TermCache
. In addition, the naming CreateableTerm
would not fit that well with an ArcTermCache
.
Due to the need to change the current TermFactory
trait I'd close this PR and prepare a new one with a sophia_term::Term
agnostic factory.
As announced this PR is closed in favour of #89.
The
TermFactory
-trait is useful in many occasions where someone tries to build dynamically new terms (especially blank nodes).However, for now only factories for
Rc<str>
andArc<str>
where provided. This PR add aSimpleFactory
when expectedTermData
can be directly converted, e.g.String
toBox<str>
and an implementation for closures.In addtion, I did a small simplification of the
TermFactory
trait.