Trait kernel::slice::AsFlattened

source ·
pub trait AsFlattened<T> {
    // Required methods
    fn as_flattened(&self) -> &[T];
    fn as_flattened_mut(&mut self) -> &mut [T];
}
Expand description

Extension trait providing a portable version of as_flattened and as_flattened_mut.

In Rust 1.80, the previously unstable slice::flatten family of methods have been stabilized and renamed from flatten to as_flattened.

This creates an issue for as long as the MSRV is < 1.80, as the same functionality is provided by different methods depending on the compiler version.

This extension trait solves this by abstracting as_flatten and calling the correct method depending on the Rust version.

This trait can be removed once the MSRV passes 1.80.

Required Methods§

source

fn as_flattened(&self) -> &[T]

Takes a &[[T; N]] and flattens it to a &[T].

This is an portable layer on top of as_flattened; see its documentation for details.

source

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

Takes a &mut [[T; N]] and flattens it to a &mut [T].

This is an portable layer on top of as_flattened_mut; see its documentation for details.

Implementations on Foreign Types§

source§

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

source§

fn as_flattened(&self) -> &[T]

source§

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

Implementors§