[][src]Trait alloc_wg::iter::TryExtend

pub trait TryExtend<A> {
    type Err;
    fn try_extend<T: IntoIterator<Item = A>>(
        &mut self,
        iter: T
    ) -> Result<(), Self::Err>; }

Extend a collection "fallibly" with the contents of an iterator.

Associated Types

type Err

Loading content...

Required methods

fn try_extend<T: IntoIterator<Item = A>>(
    &mut self,
    iter: T
) -> Result<(), Self::Err>

Extends a collection "fallibly" with the contents of an iterator.

Examples

Basic usage:

use alloc_wg::{iter::TryExtend, vec};

// You can extend a Vec<char> with some chars:
let mut message = vec!['a', 'b', 'c'];

message.try_extend(['d', 'e', 'f'].iter())?;

assert_eq!(vec!['a', 'b', 'c', 'd', 'e', 'f'], message);
Loading content...

Implementors

impl<'a, A: AllocRef> TryExtend<&'a char> for String<A>[src]

type Err = TryReserveError

impl<'a, A: AllocRef> TryExtend<&'a str> for String<A>[src]

type Err = TryReserveError

impl<'a, A: AllocRef> TryExtend<Cow<'a, str>> for String<A>[src]

type Err = TryReserveError

impl<'a, T: 'a + Copy, A> TryExtend<&'a T> for Vec<T, A> where
    A: AllocRef
[src]

type Err = TryReserveError

impl<A: AllocRef> TryExtend<char> for String<A>[src]

type Err = TryReserveError

impl<A: AllocRef, B: AllocRef> TryExtend<String<B>> for String<A>[src]

type Err = TryReserveError

impl<T, A: AllocRef> TryExtend<T> for Vec<T, A>[src]

type Err = TryReserveError

Loading content...