mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 15:54:15 +00:00
15 lines
329 B
Rust
15 lines
329 B
Rust
fn a<'a>() -> &'a isize {
|
|
let vec = vec![1, 2, 3, 4];
|
|
let vec: &[isize] = &vec;
|
|
let tail = match vec {
|
|
&[_a, ref tail @ ..] => &tail[0],
|
|
_ => panic!("foo")
|
|
};
|
|
tail //~ ERROR cannot return value referencing local variable `vec`
|
|
}
|
|
|
|
fn main() {
|
|
let fifth = a();
|
|
println!("{}", *fifth);
|
|
}
|