Macro cons::cons
[−]
[src]
macro_rules! cons { () => { ... }; ($h:expr) => { ... }; ($h:expr, $t:expr) => { ... }; }
Macro for prepending an element to the front of a ConsList
.
Examples
#[macro_use] extern crate cons; extern crate cons_list; use cons_list::ConsList; // Create an empty ConsList let list: ConsList<i32> = cons!(); assert_eq!(list, ConsList::<i32>::new()); // Create a ConsList with one element let list = cons!(1); assert_eq!(list, ConsList::new().append(1)); // Prepend an element to a ConList let head = "Hello"; let tail = cons!("World"); let list = cons!(head, tail); assert_eq!(list, ConsList::new().append("World").append("Hello"));