How do we read qualifiers such as &mut ref mut v. Is there a useful mnemonic to read them. Also please explain why the order in which qualifiers appear is important.
Nevertheless, a word about &mut and ref mut in pattern bindings: since patterns match existing structure, a &mut in effect "undoes" a reference. The ref mut "creates" a reference when binding. For example:
&mut x matches &mut 1, and x is set to 1.
ref mut x matches 1, and x is set to &mut 1.
ref mut x matches &mut 1, and x is set to &mut &mut 1 (which is already probably unwanted).
&mut ref mut x matches &mut 1, and the &mut ref mut "undoes" itself; x is set to &mut 1.
The last one is what happens in the example, since as_mut produces Result<&mut A, &mut B>.