Trait bumpalo::collections::CollectIn[][src]

pub trait CollectIn: Iterator + Sized {
    fn collect_in<C: FromIteratorIn<Self::Item>>(self, alloc: C::Alloc) -> C { ... }
}
Expand description

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

Provided methods

Collect all items from an iterator, into a collection parameterized by an allocator. Similar to Iterator::collect::<C>().

#[cfg(feature = "collections")]

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]);

Implementors