mirror of https://github.com/KaiserY/trpl-zh-cn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
918 B
20 lines
918 B
3 years ago
|
$ cargo run
|
||
|
Compiling unsafe-example v0.1.0 (file:///projects/unsafe-example)
|
||
2 years ago
|
error[E0499]: cannot borrow `*values` as mutable more than once at a time
|
||
|
--> src/main.rs:6:31
|
||
3 years ago
|
|
|
||
2 years ago
|
1 | fn split_at_mut(values: &mut [i32], mid: usize) -> (&mut [i32], &mut [i32]) {
|
||
|
| - let's call the lifetime of this reference `'1`
|
||
3 years ago
|
...
|
||
2 years ago
|
6 | (&mut values[..mid], &mut values[mid..])
|
||
|
| --------------------------^^^^^^--------
|
||
|
| | | |
|
||
|
| | | second mutable borrow occurs here
|
||
3 years ago
|
| | first mutable borrow occurs here
|
||
2 years ago
|
| returning this value requires that `*values` is borrowed for `'1`
|
||
1 month ago
|
|
|
||
|
= help: use `.split_at_mut(position)` to obtain two mutable non-overlapping sub-slices
|
||
3 years ago
|
|
||
|
For more information about this error, try `rustc --explain E0499`.
|
||
6 months ago
|
error: could not compile `unsafe-example` (bin "unsafe-example") due to 1 previous error
|