2012-12-08 20:22:43 +00:00
|
|
|
fn a() -> &[int] {
|
|
|
|
let vec = [1, 2, 3, 4];
|
2013-03-15 15:24:24 -04:00
|
|
|
let tail = match vec {
|
|
|
|
[_, ..tail] => tail, //~ ERROR does not live long enough
|
2013-05-06 00:18:51 +02:00
|
|
|
_ => fail!("a")
|
2012-12-08 20:22:43 +00:00
|
|
|
};
|
2013-02-15 02:44:18 -08:00
|
|
|
tail
|
2012-12-08 20:22:43 +00:00
|
|
|
}
|
|
|
|
|
2013-02-27 03:58:46 +09:00
|
|
|
fn b() -> &[int] {
|
|
|
|
let vec = [1, 2, 3, 4];
|
2013-03-15 15:24:24 -04:00
|
|
|
let init = match vec {
|
|
|
|
[..init, _] => init, //~ ERROR does not live long enough
|
2013-05-06 00:18:51 +02:00
|
|
|
_ => fail!("b")
|
2013-02-27 03:58:46 +09:00
|
|
|
};
|
|
|
|
init
|
2012-12-08 20:22:43 +00:00
|
|
|
}
|
2013-02-27 03:58:46 +09:00
|
|
|
|
|
|
|
fn c() -> &[int] {
|
|
|
|
let vec = [1, 2, 3, 4];
|
2013-03-15 15:24:24 -04:00
|
|
|
let slice = match vec {
|
|
|
|
[_, ..slice, _] => slice, //~ ERROR does not live long enough
|
2013-05-06 00:18:51 +02:00
|
|
|
_ => fail!("c")
|
2013-02-27 03:58:46 +09:00
|
|
|
};
|
|
|
|
slice
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|