We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
See the following code
#![feature(box_patterns)] struct A { b: u8, c: u8, } struct S<T>(T); fn foo_s(a: &mut Option<S<A>>) { match a { &mut Some(S(A{ref mut b,ref mut c})) => println!("{}{}",b,c), &mut None => println!("none") } } fn foo_box(a: &mut Option<Box<A>>) { match a { &mut Some(box A{ref mut b,ref mut c}) => println!("{}{}",b,c), &mut None => println!("none") } }
foo_s compiles fine, but foo_box generates an error:
foo_s
foo_box
<anon>:19:35: 19:44 error: cannot borrow `a.0` (here through borrowing `a.0.c`) as mutable more than once at a time [E0499] <anon>:19 &mut Some(box A{ref mut b,ref mut c}) => println!("{}{}",b,c), ^~~~~~~~~ <anon>:19:35: 19:44 help: see the detailed explanation for E0499 <anon>:19:25: 19:34 note: previous borrow of `a.0` occurs here (through borrowing `a.0.b`); the mutable borrow prevents subsequent moves, borrows, or modification of `a.0` until the borrow ends <anon>:19 &mut Some(box A{ref mut b,ref mut c}) => println!("{}{}",b,c), ^~~~~~~~~ <anon>:21:6: 21:6 note: previous borrow ends here <anon>:18 match a { <anon>:19 &mut Some(box A{ref mut b,ref mut c}) => println!("{}{}",b,c), <anon>:20 &mut None => println!("none") <anon>:21 } ^
The text was updated successfully, but these errors were encountered:
This looks like a duplicate of #30104.
Sorry, something went wrong.
Indeed!
No branches or pull requests
See the following code
foo_s
compiles fine, butfoo_box
generates an error:The text was updated successfully, but these errors were encountered: