macro_rules! py_list {
($exp:expr, $variable:pat, $collection:ident $(, $boolean_exp:expr )? ) => { ... };
}Expand description
The macro takes an expression to use in a for loop, a pattern for this, a collection and a optional boolean expression, all of them separated with commas.
ยงExamples
Because here we used a boolean the default code never reaches.
let vec = vec![1, 2, 3];
#[allow(unreachable_code)] // needed here to prevent warnings
let vec = py_list![*i += 10, i, vec,*i != 2];
assert_eq!(vec, vec![11, 2, 13]);