Trait slice_utils::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]);

Object Safety§

This trait is not object safe.

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> ContiguousMut for [T]

source§

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

source§

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

source§

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

Implementors§