Skip to content

Commit 99af0d5

Browse files
committed
new test case demonstrating ability to return ptr to interior of option
1 parent 3196586 commit 99af0d5

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
fn get<T>(opt: &option<T>) -> &T {
2+
match *opt {
3+
some(ref v) => v,
4+
none => fail ~"none"
5+
}
6+
}
7+
8+
fn main() {
9+
let mut x = some(23);
10+
11+
{
12+
let y = get(&x);
13+
assert *y == 23;
14+
}
15+
16+
x = some(24);
17+
18+
{
19+
let y = get(&x);
20+
assert *y == 24;
21+
}
22+
}

0 commit comments

Comments
 (0)