new test case demonstrating ability to return ptr to interior of option

This commit is contained in:
Niko Matsakis 2012-08-07 07:57:35 -07:00
parent 31965860c7
commit 99af0d5480

View File

@ -0,0 +1,22 @@
fn get<T>(opt: &option<T>) -> &T {
match *opt {
some(ref v) => v,
none => fail ~"none"
}
}
fn main() {
let mut x = some(23);
{
let y = get(&x);
assert *y == 23;
}
x = some(24);
{
let y = get(&x);
assert *y == 24;
}
}