Trait allocator_api2::SliceExt
source · pub trait SliceExt<T> {
// Required methods
fn to_vec_in<A: Allocator>(&self, alloc: A) -> Vec<T, A>
where T: Clone;
fn repeat(&self, n: usize) -> Vec<T, Global>
where T: Copy;
// Provided method
fn to_vec(&self) -> Vec<T, Global>
where T: Clone { ... }
}
Expand description
Slice methods that use Box
and Vec
from this crate.
Required Methods§
sourcefn to_vec_in<A: Allocator>(&self, alloc: A) -> Vec<T, A>where
T: Clone,
fn to_vec_in<A: Allocator>(&self, alloc: A) -> Vec<T, A>where T: Clone,
Copies self
into a new Vec
with an allocator.
Examples
#![feature(allocator_api)]
use std::alloc::System;
let s = [10, 40, 30];
let x = s.to_vec_in(System);
// Here, `s` and `x` can be modified independently.
Provided Methods§
Object Safety§
This trait is not object safe.