macro_rules! list {
(@push $ret:ident, $item:expr) => { ... };
(@push $ret:ident, @ $item:expr) => { ... };
(@push $ret:ident, $item:expr, $($items:tt)+) => { ... };
(@push $ret:ident, @ $item:expr, $($items:tt)+) => { ... };
(, $($items:tt)+) => { ... };
($($items:tt)+) => { ... };
() => { ... };
}Expand description
Provides a lisp-like syntax for constructing lists.
ยงExample
use tulisp::{list, TulispObject, Error};
fn main() -> Result<(), Error> {
// Create a list with 3 values inside.
let list1 = list!(
,10.into()
,"hello".into()
,5.2.into()
)?;
assert_eq!(
list1.to_string(),
r#"(10 "hello" 5.2)"#
);
// Create a list that splices `list1` in the second pos.
let list2 = list!(
,20.into()
,@list1.clone()
,list1
,"world".into()
)?;
assert_eq!(
list2.to_string(),
r#"(20 10 "hello" 5.2 (10 "hello" 5.2) "world")"#
);
Ok(())
}