// Change this:
match &opt.v {
&Some(OptVal::Arr(ref mut set)) => {
// your code here
}
_ => {}
}
// To this:
match &mut opt.v {
Some(OptVal::Arr(set)) => {
// your code here
}
_ => {}
}
// Or use if-let (cleaner):
if let Some(OptVal::Arr(set)) = &mut opt.v {
// your code here
}
The problem: you used &opt.v (immutable) but tried to get ref mut set (mutable). You need &mut opt.v to modify the data inside.