Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(unreachable_code)]
- fn main() {
- println!("{:?}", {
- let mut x = Some(1); match x { Some(ref y) => x = None, _ => () }; x
- });
- }
- /* ~~~~=== stderr ===~~~~
- Compiling playground v0.0.1 (file:///playground)
- warning: unused variable: `y`
- --> src/main.rs:6:49
- |
- 6 | let mut x = Some(1); match x { Some(ref y) => x = None, _ => () }; x
- | ^ help: consider using `_y` instead
- |
- = note: #[warn(unused_variables)] on by default
- error[E0506]: cannot assign to `x` because it is borrowed
- --> src/main.rs:6:55
- |
- 6 | let mut x = Some(1); match x { Some(ref y) => x = None, _ => () }; x
- | ----- ^^^^^^^^ assignment to borrowed `x` occurs here
- | |
- | borrow of `x` occurs here
- error: aborting due to previous error
- For more information about this error, try `rustc --explain E0506`.
- error: Could not compile `playground`.
- To learn more, run the command again with --verbose.
- */
- /* ~~~~=== stdout ===~~~~
- */
Add Comment
Please, Sign In to add comment