pub trait ToSlice<T> {
// Required methods
fn to_slice(&self) -> &[T];
fn len(&self) -> usize;
fn is_empty(&self) -> bool;
fn alloc_len(&self) -> usize;
fn try_resize(&mut self, len: usize) -> Result<(), ErrorReason>;
}Expand description
A trait to convert a type into a slice.
Required Methods§
Sourcefn alloc_len(&self) -> usize
fn alloc_len(&self) -> usize
Gets the allocated length of a storage.
It’s expected that self.alloc_len() >= self.len()
in all cases.
Sourcefn try_resize(&mut self, len: usize) -> Result<(), ErrorReason>
fn try_resize(&mut self, len: usize) -> Result<(), ErrorReason>
Resizes the storage to support at least len elements or
returns an error if resizing isn’t supported.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".