new test case demonstrating ability to return ptr to interior of option
This commit is contained in:
parent
31965860c7
commit
99af0d5480
22
src/test/run-pass/region-return-interior-of-option.rs
Normal file
22
src/test/run-pass/region-return-interior-of-option.rs
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user