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 the length of cons.

Examples
assert_eq!(cons!(1, 2, 3, 4, 5).len(), 5);

Returns if the cons is empty.

Examples
assert!(().is_empty());
assert!(!cons!(1, 2, 3, 4, 5).is_empty());

Gets an element by type from this cons.

Examples
assert_eq!(*cons!(1f32, 1i32, 1u32).get::<i32, _>(), 1i32);

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]);

Reverse this cons.

Examples
let cons!(c1, c2, c3, c4, c5) = cons!(1, 2, 3, 4, 5).rev();
assert_eq!([c1, c2, c3, c4, c5], [5, 4, 3, 2, 1]);

Implementations on Foreign Types

Implementors