pub trait SliceExt {
type Item;
// Required methods
fn bitcoin_as_chunks<const N: usize>(
&self,
) -> (&[[Self::Item; N]], &[Self::Item]);
fn bitcoin_as_chunks_mut<const N: usize>(
&mut self,
) -> (&mut [[Self::Item; N]], &mut [Self::Item]);
fn get_array<const ARRAY_LEN: usize>(
&self,
offset: usize,
) -> Option<&[Self::Item; ARRAY_LEN]>;
fn split_first_chunk<const ARRAY_LEN: usize>(
&self,
) -> Option<(&[Self::Item; ARRAY_LEN], &[Self::Item])>;
fn split_last_chunk<const ARRAY_LEN: usize>(
&self,
) -> Option<(&[Self::Item], &[Self::Item; ARRAY_LEN])>;
}Expand description
Extension trait for slice.
Required Associated Types§
Required Methods§
Sourcefn bitcoin_as_chunks<const N: usize>(
&self,
) -> (&[[Self::Item; N]], &[Self::Item])
fn bitcoin_as_chunks<const N: usize>( &self, ) -> (&[[Self::Item; N]], &[Self::Item])
Splits up the slice into a slice of arrays and a remainder.
Note that N must not be zero:
ⓘ
let slice = [1, 2, 3];
let _fail = slice.bitcoin_as_chunks::<0>(); // Fails to compileSourcefn bitcoin_as_chunks_mut<const N: usize>(
&mut self,
) -> (&mut [[Self::Item; N]], &mut [Self::Item])
fn bitcoin_as_chunks_mut<const N: usize>( &mut self, ) -> (&mut [[Self::Item; N]], &mut [Self::Item])
Splits up the slice into a slice of arrays and a remainder.
Note that N must not be zero:
ⓘ
let mut slice = [1, 2, 3];
let _fail = slice.bitcoin_as_chunks_mut::<0>(); // Fails to compileSourcefn get_array<const ARRAY_LEN: usize>(
&self,
offset: usize,
) -> Option<&[Self::Item; ARRAY_LEN]>
fn get_array<const ARRAY_LEN: usize>( &self, offset: usize, ) -> Option<&[Self::Item; ARRAY_LEN]>
Tries to access a sub-array of length ARRAY_LEN at the specified offset.
Returns None in case of out-of-bounds access.
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.