You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code seems like it should work, but it produces a cryptic error:
fnmain(){let f = box Some((box 1i, box 2i));let g = match f { box Some((a, b)) => (*b,*a), _ => (0,0)};println!("{}", g);}
<anon>:3:36: 3:37 error: use of partially moved value: `f#0#1`
<anon>:3 let g = match f { box Some((a, b)) => (*b, *a), _ => (0,0) };
^
<anon>:3:33: 3:34 note: `f#0#0` moved here because it has type `Box<int>`, which is moved by default (use `ref` to override)
<anon>:3 let g = match f { box Some((a, b)) => (*b, *a), _ => (0,0) };
^
error: aborting due to previous error
However, removing the outermost box works:
fnmain(){let f = Some((box 1i, box 2i));let g = match f {Some((a, b)) => (*b,*a), _ => (0,0)};println!("{}", g);// => (2, 1)}
Alternatively, matching on an rvalue also works:
fnmain(){let f = box Some((box 1i, box 2i));let g = match f.clone(){ box Some((a, b)) => (*b,*a), _ => (0,0)};println!("{}", g);// => (2, 1)}
The text was updated successfully, but these errors were encountered:
The following code seems like it should work, but it produces a cryptic error:
However, removing the outermost
box
works:Alternatively, matching on an rvalue also works:
The text was updated successfully, but these errors were encountered: