Skip to main content

ContiguousMut

Trait ContiguousMut 

Source
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§

Source

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".

Implementations on Foreign Types§

Source§

impl<S> ContiguousMut for &mut S
where S: ContiguousMut + ?Sized,

Source§

fn contiguous_mut(&mut self) -> &mut [S::Output]

Source§

impl<T, const N: usize> ContiguousMut for [T; N]

Source§

fn contiguous_mut(&mut self) -> &mut [T]

Source§

impl<T> ContiguousMut for [T]

Source§

fn contiguous_mut(&mut self) -> &mut [T]

Implementors§