pub trait OrdesCons<Input> {
type Output;
// Required method
fn cons(self, value: Input) -> Self::Output;
}
Required Associated Types§
Required Methods§
sourcefn cons(self, value: Input) -> Self::Output
fn cons(self, value: Input) -> Self::Output
Add an element to the start of self
and return the sum.
Examples
Using an array:
let foo: [u8; 4] = [1, 2, 3, 4];
let foo = foo.cons(0);
assert_eq!(foo, [0, 1, 2, 3, 4]);
Using a tuple:
let foo = (false, b'c', "d");
let foo = foo.cons('a');
assert_eq!(foo, ('a', false, b'c', "d"));