Issue by thestinger
Wednesday Mar 12, 2014 at 21:15 GMT
For earlier discussion, see rust-lang/rust#12853
This issue was labelled with: A-lifetimes in the Rust repository
The following works:
fn foo<'a>(xs: &'a [int]) -> &'a [int] {
if xs.len() & 1 == 0 {
static ys: &'static [int] = &[1, 2, 3];
ys
} else {
xs
}
}
This should also work, but does not:
fn foo<'a>(xs: &'a [int]) -> &'a [int] {
if xs.len() & 1 == 0 {
&[1, 2, 3]
} else {
xs
}
}