This involves adding a new keyword, which I am against (unless its already reserved?), and +1 to @stebalien’s comment, thats a much better and more orthogonal way to do it. We dont need to add functionality that mirrors something else at the moment.
macro_rules! with_mut {
($($v:ident),+ in $e:expr) => {
let ($($v,)+) = {
let ($(mut $v,)+) = ($($v,)+);
$e;
($($v,)+)
}
}
}
fn main() {
let a = 0;
let b = 0;
with_mut!(a, b in {
a = 1;
b = 2;
});
println!("{}, {}", a, b);
}
Why? The gain in number of symbols is small and the loss in readability for people not intimately familiar with your code is huge. Additionally, imagine that you have a bug in your macros (perhaps, someone accidentally writes let mut (a, mut b, c)) - how easy would it be to debug your code?