ik1ne
1
let mut opt = Some(1);
if let Some(mut inner) = opt.as_mut() {
*inner = 2;
let mut other_usize = 3;
inner = &mut other_usize;
*inner = 4;
}
The type of inner
is mut &mut usize
.
How do I use ref mut
to achieve the same thing?
mut ref mut
is tentatively planned for edition 2024 but not yet stable, or, apparently, complete.
In the meanwhile you can rebind after the pattern matching.
(Or just use binding modes like in the OP.)
1 Like
system
Closed
3
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.