Trait Append

Source
pub trait Append<T> {
    type Output: PrefixedWith<Self> + Lookup<T, Self::Navigator>;
    type Navigator;

    // Required method
    fn append(self, t: T) -> (Self::Output, Handle<T, Self::Navigator>);
}
Expand description

Describes the result of appending T to the borrow-bag. This is useful in specifying the return type when creating/modifying a BorrowBag in a function.

§Examples

type SingleItemBag<T> = BorrowBag<(T, ())>;
type SingleItemHandle<T> = Handle<T, <() as Append<T>>::Navigator>;

fn single_item_bag<T>(t: T) -> (SingleItemBag<T>, SingleItemHandle<T>) {
    BorrowBag::new().add(t)
}

Required Associated Types§

Source

type Output: PrefixedWith<Self> + Lookup<T, Self::Navigator>

The resulting BorrowBag type parameter after adding an element of type T.

Source

type Navigator

A type describing how to borrow the T which is added.

If the output type is (X, (Y, (Z, ()))), we’re adding the Z and so our Navigator will be (Skip, (Skip, Take))

Required Methods§

Source

fn append(self, t: T) -> (Self::Output, Handle<T, Self::Navigator>)

Append the element, returning a new collection and a handle to borrow the element back.

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.

Implementations on Foreign Types§

Source§

impl<T> Append<T> for ()

Source§

type Output = (T, ())

Source§

type Navigator = Take

Source§

fn append(self, t: T) -> (Self::Output, Handle<T, Self::Navigator>)

Source§

impl<T, U, V> Append<T> for (U, V)
where V: Append<T>,

Source§

type Output = (U, <V as Append<T>>::Output)

Source§

type Navigator = (Skip, <V as Append<T>>::Navigator)

Source§

fn append(self, t: T) -> (Self::Output, Handle<T, Self::Navigator>)

Implementors§