]>
git.proxmox.com Git - rustc.git/blob - tests/ui/closures/2229_closure_analysis/run_pass/mut_ref.rs
4 // Test that we can mutate a place through a mut-borrow
5 // that is captured by the closure
7 // Check that we can mutate when one deref is required
9 let mut x
= String
::new();
19 // Similar example as mut_ref_1, we don't deref the imm-borrow here,
20 // and so we are allowed to mutate.
22 let x
= String
::new();
23 let y
= String
::new();
25 let m_ref_x
= &mut ref_x
;
34 // Check that we can mutate when multiple derefs of mut-borrows are required to reach
36 // It works because all derefs are mutable, if either of them was an immutable
37 // borrow, then we would not be able to deref.
39 let mut x
= String
::new();
40 let mut mref_x
= &mut x
;
41 let m_mref_x
= &mut mref_x
;
44 **m_mref_x
= String
::new();