Trait Lengthen

unsafe trait Lengthen<T>: Sized + GenericSequence<T>

Defines any GenericSequence which can be lengthened or extended by appending or prepending an element to it.

Any lengthened sequence can be shortened back to the original using pop_front or pop_back

Associated Types

type Longer: TraitBound { trait_: Path { path: "Shorten", id: Id(143), args: Some(AngleBracketed { args: [Type(Generic("T"))], constraints: [AssocItemConstraint { name: "Shorter", args: None, binding: Equality(Type(Generic("Self"))) }] }) }, generic_params: [], modifier: None }

GenericSequence that has one more element than Self

Required Methods

fn append(self: Self, last: T) -> <Self as >::Longer

Returns a new array with the given element appended to the end of it.

Example:

# use generic_array::{arr, sequence::Lengthen};
# fn main() {
let a = arr![i32; 1, 2, 3];

let b = a.append(4);

assert_eq!(b, arr![i32; 1, 2, 3, 4]);
# }
fn prepend(self: Self, first: T) -> <Self as >::Longer

Returns a new array with the given element prepended to the front of it.

Example:

# use generic_array::{arr, sequence::Lengthen};
# fn main() {
let a = arr![i32; 1, 2, 3];

let b = a.prepend(4);

assert_eq!(b, arr![i32; 4, 1, 2, 3]);
# }

Implementors