devela::_dep::bumpalo::collections

Trait CollectIn

pub trait CollectIn: Sized + Iterator {
    // Provided method
    fn collect_in<C>(self, alloc: <C as FromIteratorIn<Self::Item>>::Alloc) -> C
       where C: FromIteratorIn<Self::Item> { ... }
}
Available on crate feature dep_bumpalo only.
Expand description

Extension trait for iterators, in order to allow allocator-parameterized collections to be constructed more easily.

Provided Methods§

fn collect_in<C>(self, alloc: <C as FromIteratorIn<Self::Item>>::Alloc) -> C
where C: FromIteratorIn<Self::Item>,

Collect all items from an iterator, into a collection parameterized by an allocator. Similar to Iterator::collect.

let bump = Bump::new();

let str = "hello, world!".to_owned();
let bump_str: String = str.chars().collect_in(&bump);
assert_eq!(&bump_str, &str);

let nums: Vec<i32> = (0..=3).collect_in::<Vec<_>>(&bump);
assert_eq!(&nums, &[0,1,2,3]);

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§

§

impl<I> CollectIn for I
where I: Iterator,