pub trait ContiguousMut: SliceMut + Unique {
// Required method
fn contiguous_mut(&mut self) -> &mut [Self::Output];
}
Expand description
A slice whose backing is contiguous in memory.
See also ContiguousBorrowed
.
Required Methods§
Sourcefn contiguous_mut(&mut self) -> &mut [Self::Output]
fn contiguous_mut(&mut self) -> &mut [Self::Output]
Get a mutable reference to the contiguous backing of this slice.
The returned slice should behave exactly like this one, e.g.
self.get_mut(n) == self.contiguous_mut().get_mut(n)
.
§Examples
let mut a = [1, 2, 3].to_vec();
let b = a.contiguous_mut();
b.copy_from_slice(&[4, 5, 6]); // method on core::slice
assert_eq!(a, [4, 5, 6]);
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.