mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 15:01:51 +00:00
14 lines
285 B
Rust
14 lines
285 B
Rust
fn flatten<'a, 'b, T>(x: &'a &'b T) -> &'a T {
|
|
x
|
|
}
|
|
|
|
fn main() {
|
|
let mut x = "original";
|
|
let y = &x;
|
|
let z = &y;
|
|
let w = flatten(z);
|
|
x = "modified";
|
|
//~^ ERROR cannot assign to `x` because it is borrowed [E0506]
|
|
println!("{}", w); // prints "modified"
|
|
}
|