pub unsafe trait FixedSizeArray<T> { fn as_slice(&self) -> &[T]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]; fn as_mut_slice(&mut self) -> &mut [T]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]; }
Utility trait implemented only on arrays of fixed size
This trait can be used to implement other traits on fixed-size arrays without causing much metadata bloat.
The trait is marked unsafe in order to restrict implementors to fixed-size arrays. User of this trait can assume that implementors have the exact layout in memory of a fixed size array (for example, for unsafe initialization).
Note that the traits AsRef
and AsMut
provide similar methods for types that may not be fixed-size arrays. Implementors should prefer those traits instead.
fn as_slice(&self) -> &[T]ⓘNotable traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]
Converts the array to immutable slice
fn as_mut_slice(&mut self) -> &mut [T]ⓘNotable traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]
Converts the array to mutable slice
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/array/trait.FixedSizeArray.html