Macro codize::clist

source ·
macro_rules! clist {
    ($sep:expr => []) => { ... };
    ($sep:expr => [ $( $body:expr ),* $(,)? ]) => { ... };
    ($sep:expr => $body:expr) => { ... };
}
Expand description

Macro for creating Lists

Note that spaces and newlines are automatically added between the items after the separator. You don’t need to specify them as part of the separator.

The default trailing separator behavior is only trail if the list is split into multiple lines. You can use List::no_trail or List::always_trail to change the behavior.

§Examples

use codize::{clist, cblock};

let expected = "call_something( a, b, c )";
let code = cblock!("call_something(", [
    clist!("," => ["a", "b", "c"]).inlined()
], ")");
assert_eq!(expected, code.to_string());

let expected =
"call_something(
    a,
    b,
    c,
)";
let code = cblock!("call_something(", [
    clist!("," => ["a", "b", "c"])
], ")");
assert_eq!(expected, code.to_string());