Trait json_ld_core::id::IntoId
source · [−]Expand description
Types that can be converted into a borrowed node reference.
This is a convenient trait is used to simplify the use of references.
For instance consider the Node::get method, used to get the objects associated to the
given reference property for a given node.
It essentially have the following signature:
ⓘ
fn get(&self, id: &Id<T, B>) -> Objects;However building a Id by hand can be tedious, especially while using Lexicon and
Vocab. It can be as verbose as node.get(&Id::Id(Lexicon::Id(MyVocab::Term))).
Thanks to IntoId which is implemented by Lexicon<V> for any type V implementing Vocab,
it is simplified into node.get(MyVocab::Term) (while the first syntax remains correct).
The signature of get becomes:
ⓘ
fn get<R: IntoId<T>>(self, id: R) -> Objects;