Trait fj_kernel::builder::ObjectArgument
source · 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§
sourcetype SameSize<R>
type SameSize<R>
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.
sourcetype SizePlusOne<R>
type SizePlusOne<R>
A return value that has one more element than the argument
Required Methods§
sourcefn num_objects(&self) -> usize
fn num_objects(&self) -> usize
Return the number of objects
sourcefn map<F, R>(self, f: F) -> Self::SameSize<R>where
F: FnMut(T) -> R,
fn map<F, R>(self, f: F) -> Self::SameSize<R>where
F: FnMut(T) -> R,
Create a return value by mapping the implementing type
sourcefn map_plus_one<F, R>(self, item: R, f: F) -> Self::SizePlusOne<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,
Create a return value with one more element