Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- println!("{:?}", {
- let v = vec![1, 2, 3, 4, 5]; let mut bytes: &mut [u8] = v.as_mut(); bytes = &mut bytes[2..]; bytes
- });
- }
- /* ~~~~=== stderr ===~~~~
- Compiling playground v0.0.1 (file:///playground)
- error[E0597]: `v` does not live long enough
- --> src/main.rs:5:65
- |
- 4 | / println!("{:?}", {
- 5 | | let v = vec![1, 2, 3, 4, 5]; let mut bytes: &mut [u8] = v.as_mut(); bytes = &mut bytes[2..]; bytes
- | | ^ borrowed value does not live long enough
- 6 | | });
- | |_____-_- borrowed value needs to live until here
- | |
- | `v` dropped here while still borrowed
- |
- = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
- error[E0506]: cannot assign to `bytes` because it is borrowed
- --> src/main.rs:5:77
- |
- 5 | let v = vec![1, 2, 3, 4, 5]; let mut bytes: &mut [u8] = v.as_mut(); bytes = &mut bytes[2..]; bytes
- | ^^^^^^^^^^^^^-----^^^^^
- | | |
- | | borrow of `bytes` occurs here
- | assignment to borrowed `bytes` occurs here
- error[E0505]: cannot move out of `bytes` because it is borrowed
- --> src/main.rs:5:102
- |
- 5 | let v = vec![1, 2, 3, 4, 5]; let mut bytes: &mut [u8] = v.as_mut(); bytes = &mut bytes[2..]; bytes
- | ----- ^^^^^ move out of `bytes` occurs here
- | |
- | borrow of `*bytes` occurs here
- error: aborting due to 3 previous errors
- error: Could not compile `playground`.
- To learn more, run the command again with --verbose.
- */
- /* ~~~~=== stdout ===~~~~
- */
Add Comment
Please, Sign In to add comment