Trait bumpalo::collections::CollectIn
source · pub trait CollectIn: Iterator + Sized {
// Provided method
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§
sourcefn collect_in<C: FromIteratorIn<Self::Item>>(self, alloc: C::Alloc) -> C
fn collect_in<C: FromIteratorIn<Self::Item>>(self, alloc: C::Alloc) -> C
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]);