collectable

Trait TryExtend

Source
pub trait TryExtend<A> {
    type Error;

    // Required method
    fn try_extend<T>(&mut self, iter: &mut T) -> Result<(), Self::Error>
       where T: Iterator<Item = A>;

    // Provided method
    fn try_extend_from_slice(&mut self, slice: &[A]) -> Result<(), Self::Error>
       where A: Clone { ... }
}
Expand description

Fallible equivalent of core::iter::Extend - extends a collection with the contents of an iterator, but with the option to return an error in the event the container’s capacity has been exceeded.

Required Associated Types§

Source

type Error

Error type.

Required Methods§

Source

fn try_extend<T>(&mut self, iter: &mut T) -> Result<(), Self::Error>
where T: Iterator<Item = A>,

Try to extend the collection from the given iterator.

Provided Methods§

Source

fn try_extend_from_slice(&mut self, slice: &[A]) -> Result<(), Self::Error>
where A: Clone,

Try to extend the collection from the given slice.

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§