pub trait Buf<T>:
Default
+ Debug
+ Deref<Target = [T]>
+ DerefMut
+ Send
+ Sync
+ 'static
+ Sealed {
// Required methods
fn zeroed(len: usize) -> Self;
fn zeroed_arr2(len: usize) -> impl Buf<[T; 2]>;
fn capacity(&self) -> usize;
fn set_len(&mut self, new_len: usize);
fn grow_zeroed(&mut self, new_size: usize);
}
Required Methods§
Sourcefn zeroed(len: usize) -> Self
fn zeroed(len: usize) -> Self
Create a new Buf
of length len
with all elements set to zero.
Implementations of this directly allocate zeroed memory and do not write zeroes to the elements explicitly.
Sourcefn zeroed_arr2(len: usize) -> impl Buf<[T; 2]>
fn zeroed_arr2(len: usize) -> impl Buf<[T; 2]>
Create a new Buf
of the same kind but for two-element arrays of
`T``.
This method is useful in methods generic over Buf which need a temporary
buffer over arrays of size two of T
, that is the same kind of buffer
the method is called with. That is, a fn foo(b: impl Buf<T>)
called with a HugePageMemory
can use this method to create a
HugePageMemory<[T;2]>
.
Sourcefn grow_zeroed(&mut self, new_size: usize)
fn grow_zeroed(&mut self, new_size: usize)
Grow the Buf
to new_size
and fill with zeroes.
let mut v: Vec<u8> = Vec::zeroed(20);
assert_eq!(20, v.len());
v.grow_zeroed(40);
assert_eq!(40, v.len());
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.