mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-01-23 23:50:25 +08:00
22 lines
861 B
Plaintext
22 lines
861 B
Plaintext
$ cargo run
|
|
Compiling unsafe-example v0.1.0 (file:///projects/unsafe-example)
|
|
error[E0499]: cannot borrow `*slice` as mutable more than once at a time
|
|
--> src/main.rs:6:30
|
|
|
|
|
1 | fn split_at_mut(slice: &mut [i32], mid: usize) -> (&mut [i32], &mut [i32]) {
|
|
| - let's call the lifetime of this reference `'1`
|
|
...
|
|
6 | (&mut slice[..mid], &mut slice[mid..])
|
|
| -------------------------^^^^^--------
|
|
| | | |
|
|
| | | second mutable borrow occurs here
|
|
| | first mutable borrow occurs here
|
|
| returning this value requires that `*slice` is borrowed for `'1`
|
|
|
|
error: aborting due to previous error
|
|
|
|
For more information about this error, try `rustc --explain E0499`.
|
|
error: could not compile `unsafe-example`
|
|
|
|
To learn more, run the command again with --verbose.
|