pub trait Cons: Sized {
const LEN: usize;
fn len(&self) -> usize { ... }
fn is_empty(&self) -> bool { ... }
fn get<T, Index>(&self) -> &T
where
Self: ConsGetter<T, Index>,
{ ... }
fn get_mut<T, Index>(&mut self) -> &mut T
where
Self: ConsGetter<T, Index>,
{ ... }
fn append<RHS: Cons>(self, rhs: RHS) -> <Self as Append<RHS>>::Output
where
Self: Append<RHS>,
{ ... }
fn rev(self) -> <Self as IntoRev>::Output
where
Self: IntoRev,
{ ... }
}
Expand description
Trait for a Cons.
Required Associated Constants
Provided Methods
Returns if the cons is empty.
Examples
assert!(().is_empty());
assert!(!cons!(1, 2, 3, 4, 5).is_empty());
fn get<T, Index>(&self) -> &T where
Self: ConsGetter<T, Index>,
fn get<T, Index>(&self) -> &T where
Self: ConsGetter<T, Index>,
Gets an element by type from this cons.
Examples
assert_eq!(*cons!(1f32, 1i32, 1u32).get::<i32, _>(), 1i32);
fn get_mut<T, Index>(&mut self) -> &mut T where
Self: ConsGetter<T, Index>,
fn get_mut<T, Index>(&mut self) -> &mut T where
Self: ConsGetter<T, Index>,
Mutably gets an element by type from this cons.
Examples
let mut c = cons!(1f32, 1i32, 1u32);
*c.get_mut::<i32, _>() = 10;
assert_eq!(c, cons!(1f32, 10i32, 1u32));
Append to this cons.
Examples
let cons!(c1, c2, c3, c4, c5) = cons!(1, 2).append(cons!(3, 4, 5));
assert_eq!([c1, c2, c3, c4, c5], [1, 2, 3, 4, 5]);