On 12/24/13 2:42 PM, Vadim wrote:

type T<'s> = 's || -> int;

fn man_or_boy(k:int) -> int {
     fn A(k:int, x1:&T, x2:&T, x3:&T, x4:&T, x5:&T) -> int {
         let mut k = k;

         let mut B: T = || {fail!()};
         B = || {
             k -= 1;
             A(k, &B, x1, x2, x3, x4)
         };

         if k <= 0 {
             (*x4)() + (*x5)()
         } else {
             B()
         }
     }
     A(k, &||{1}, &||{-1}, &||{-1}, &||{1}, &||{0})
}

Are you sure that calling a closure via an &-pointer `&||` isn't exploiting a bug in the borrow checker that can cause unsoundness (see "The Case of the Recurring Closure")? Niko, can you weigh in?

Patrick

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to