pub trait ObjectArgument<T>: IntoIterator<Item = T> {
    type SameSize<R>;
    type SizePlusOne<R>;

    fn num_objects(&self) -> usize;
    fn map<F, R>(self, f: F) -> Self::SameSize<R>
    where
        F: FnMut(T) -> R
; fn map_plus_one<F, R>(self, item: R, f: F) -> Self::SizePlusOne<R>
    where
        F: FnMut(T) -> R
; }
Expand description

Pass objects to a builder method

Many builder methods receive objects as arguments, and many builder arguments return objects back, based on their input. In the general case, the number of objects passed and returned is usually arbitrary, but many callers pass a specific number of objects, and expect the same number of objects back.

This trait can be used to do exactly that. It is implemented for Vec and arrays. When passing a Vec, a Vec is returned. When passing an array, an array of the same size is returned.

Required Associated Types§

The value returned, if the implementing type is passed on an argument

The return value has the same length as the implementing type, but it is not necessarily of the same type. For this reason, this associated type is generic.

A return value that has one more element than the argument

Required Methods§

Return the number of objects

Create a return value by mapping the implementing type

Create a return value with one more element

Implementations on Foreign Types§

Implementors§