Trait array_manipulation::ArrayRemove
source · [−]pub trait ArrayRemove<T, const N: usize>: Sized {
fn truncate_start<const L: usize>(self) -> [T; { _ }];
fn truncate_end<const L: usize>(self) -> [T; { _ }];
}Expand description
Holds the pop methods. Will (probably) get into core when generic-const-exprs becomes complete.
Required Methods
fn truncate_start<const L: usize>(self) -> [T; { _ }]
fn truncate_start<const L: usize>(self) -> [T; { _ }]
memcpy()s all the elements on an array except the first L ones.
Basically it creates a new fixed-size array with all the
elements except the first one. Won’t compile if N == 0.
Examples
use array_manipulation::ArrayManipulation;
let array: [u8; 4] = [1, 2, 3, 4];
let expected = [3, 4];
let result = array.truncate_start(2);
assert_eq!(expected, result);fn truncate_end<const L: usize>(self) -> [T; { _ }]
fn truncate_end<const L: usize>(self) -> [T; { _ }]
memcpy()s all the elements on an array except the last L ones.
Basically it creates a new fixed-size array with all the
elements except the first one. Won’t compile if N == 0.
Examples
use array_manipulation::ArrayManipulation;
let array: [u8; 4] = [1, 2, 3, 4];
let expected = [1, 2];
let result = array.truncate_end(2);
assert_eq!(expected, result);