pub trait CollectionExt<T>: Sizedwhere
    T: IntoIterator,
{ fn into_first(self) -> T::Item; fn into_last(self) -> T::Item; fn expect_element<Err: Display>(
        self,
        msg_fn: impl FnOnce() -> Err
    ) -> T::Item; fn into_element(self) -> T::Item { ... } }
Expand description

Extension methods for collections.

Required Methods§

Consumes the collection and returns its first element.

This method panics if the collection does not have at least one element.

Consumes the collection and returns its last element.

This method panics if the collection does not have at least one element.

Consumes the collection and returns its only element.

This method panics with the given error function’s return value if the collection does not have exactly one element.

Provided Methods§

Consumes the collection and returns its only element.

This method panics if the collection does not have exactly one element.

Implementors§