Turns out the issue was borrowing from a reborrowed value. i.e. this
doesn't work:
fn rereborrow(v: &r/int) -> &r/int {
&*&*v
}
I've filed an issue: https://github.com/mozilla/rust/issues/4285
Incidentally, I can make my original code work by eliminating the
intermediate borrow:
struct T1 { value: int }
struct T2 { t1: option::Option<~T1> }
fn value(t2: &r/T2, def: &r/int) -> &r/int {
match t2.t1 {
Some(~T1{value: ref value}) => value,
None => def
}
}
fn main() {
let t2 = ~T2{ t1: Some(~T1{ value: 5 }) };
let def = ~0;
io::println(fmt!("%d", *value(t2, def)));
}
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev