pub trait ComponentSlice<T> {
// Required methods
fn as_slice(&self) -> &[T];
fn as_mut_slice(&mut self) -> &mut [T];
}use bytemuck::cast_slice() instead
Expand description
Casting the struct to slices of its components
Required Methods§
Sourcefn as_slice(&self) -> &[T]
👎Deprecated: use bytemuck::cast_slice() instead; or at least call it like ComponentSlice::as_slice(px)
fn as_slice(&self) -> &[T]
use bytemuck::cast_slice() instead; or at least call it like ComponentSlice::as_slice(px)
The components interpreted as an array, e.g. one RGB expands to 3 elements.
It’s implemented for individual pixels as well as slices of pixels.
Sourcefn as_mut_slice(&mut self) -> &mut [T]
👎Deprecated: use bytemuck::cast_slice_mut() instead; or at least call it like ComponentSlice::as_mut_slice(px)
fn as_mut_slice(&mut self) -> &mut [T]
use bytemuck::cast_slice_mut() instead; or at least call it like ComponentSlice::as_mut_slice(px)
The components interpreted as a mutable array, e.g. one RGB expands to 3 elements.
It’s implemented for individual pixels as well as slices of pixels.
If you get an error when calling this on an array, add [..]
use of unstable library feature ‘array_methods’
arr[..].as_mut_slice()Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".