pchampin / sophia_rs

Sophia: a Rust toolkit for RDF and Linked Data
Other
210 stars 23 forks source link

[WIP] Rework `TermFactory` #89

Closed MattesWhite closed 7 months ago

MattesWhite commented 3 years ago

This PR aims to rework the elements of sophia related to the TermFactory.

Like pointed out in #82 the current TermFactory trait does no longer fit into sophia with the TTerm trait.

Following the previous discussion and inspired by Code Smell: Concrete Abstraction this PR removes the TermFactory trait completely. In turn, the existing implementations for WeakHashSet is turned into a concrete TermCache that fulfils the same task. Furthermore, the traits FromData and IntoData have been added for proper conversion between TermData types. This will hopefully lead to an easier TermData handling. As you can see the implementations of FromData and IntoData allow to pass in either owned or reference types when the function signature is something like:

fn foo(td: IntoData<Arc<str>>) {}

fn main() {
    // all works
    foo("foo");
    foo("bar".to_string());
    let rc: Rc<str> = "baz".into();
    foo(&rc);
}

ToDo:

pchampin commented 7 months ago

Closing this PR, as it has not been finalized, and since the refactoring of 0.8 makes it moot.