cons 0.0.3

Convenience macros for the ConsList type from the cons-list crate.
Documentation

Cons

Convenience macros for the ConsList type from the cons-list crate.

Usage

Add the following dependencies to your Cargo.toml:

[dependencies]
cons = "0.0.3"
cons-list = "0.0.3"

Then add the following to your crate root:

#[macro_use] extern crate cons;
extern crate cons_list;

The cons! macro can be used as follows:

use cons_list::ConsList;

// Create an empty ConsList
let list: ConsList<i32> = cons!();

// Create a ConsList with one element
let list = cons!(1);

// Prepend an element to a ConList
let head = "Hello";
let tail = cons!("World");
let list = cons!(head, tail);

The conslist! macro can be used as follows:

use cons_list::ConsList;

// Create an empty ConsList
let list: ConsList<i32> = conslist!();

// Create a ConsList
let list = conslist!("A", "B", "C");