Trait 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§

Source

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

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§