[][src]Macro list_compression::py_list_extern

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

This macro takes an expression, a pattern, a collection, an optional boolean expression and,if the last is present,zero or more variables to pass a reference into.

It expands to a block that yield the modified collection after apply the expression.

If a boolean expression and/or a declaration of a inmutable reference is used the default code never reaches.

Examples

use list_compression::py_list_extern;
 
let mut vec = vec![1, 2, 3];
let ten = Box::new(10);
#[allow(unreachable_code)] // needed here to prevent warnings
let vec = py_list_extern![*i += **ten, i, vec,*i != 2;ten;]; 
 
assert_eq!(vec, vec![11, 2, 13]);