Trait LabelledResolve

Source
pub trait LabelledResolve<Y: LabelledResolvable> {
    // Required method
    fn labelled_resolve(
        self,
        resolver: &impl LabelResolver<Y::ResolverOutput>,
    ) -> Y;
}
Expand description

This trait is intended to be used as an impl argument in helper methods, to accept a wider range of arguments.

It should only be used where it is safe to panic if the wrong argument is provided, and where performance isn’t a primary concern.

Compared to Resolve, LabelledResolve also accepts an optional resolver, which can be used to convert label/s either directly into Self, or into values which can be used to build up self.

However, unlike Resolve, a reflexive LabelledResolve is only implemented for Self, &Self and various string labels. It doesn’t build on top of TryInto because that causes implementation collisions with labels for types which could implement TryFrom<&str>.

§Implementers

  • You should prefer to implement LabelledResolveFrom as it is easier to implement due to trait coherence rules. Sometimes you can only implement LabelledResolve however.
  • If requiring a labelled resolution in your bounds, prefer LabelledResolve because slightly more types can implement it.

Required Methods§

Source

fn labelled_resolve(self, resolver: &impl LabelResolver<Y::ResolverOutput>) -> Y

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§