[][src]Macro list_compression::py_list

macro_rules! py_list {
    ($exp:expr, $variable:pat, $collection:ident $(, $boolean_exp:expr )? ) => { ... };
}

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]);