Trait Field

Source
pub trait Field<R>: Clone {
    type Value;

    // Required method
    fn apply_sorter<V: Sorter<Self::Value>>(
        &self,
        op: &V,
        a: &R,
        b: &R,
    ) -> Ordering;
}
Available on crate feature sort only.
Expand description

Apply a Sorter to a member of a type.

By asking the type to apply the operator, we can avoid cloning potentially large objects in more complex cases of nesting. If we used Accessor directly for everything, which is a much simpler definition, there are some constructs that we cannot handle efficiently, because of nested comparisons within members of type Option, for example (i.e. in the case that a Foo is to be sorted by the a member of a contained object of type Option<Bar>.

Required Associated Types§

Required Methods§

Source

fn apply_sorter<V: Sorter<Self::Value>>(&self, op: &V, a: &R, b: &R) -> Ordering

Extract whichever member this Field obtains from R, from both a and b and apply op to the results.

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§

Source§

impl<R, F> Field<R> for F
where F: Accessor<R> + ReferenceField,

Source§

type Value = <F as Accessor<R>>::Value