pub trait OrdesPush<Input> {
type Output;
// Required method
fn push(self, value: Input) -> Self::Output;
}
Expand description
Trait for defining pushing to an array- or tuple-like data structure.
Required Associated Types§
Required Methods§
sourcefn push(self, value: Input) -> Self::Output
fn push(self, value: Input) -> Self::Output
Add an element to the end of self
and return the sum.
Examples
Using an array:
let foo: [u8; 4] = [0, 1, 2, 3];
let foo = foo.push(4);
assert_eq!(foo, [0, 1, 2, 3, 4]);
Using a tuple:
let foo = ('a', false, b'c');
let foo = foo.push("d");
assert_eq!(foo, ('a', false, b'c', "d"));