Created
June 10, 2013 19:53
-
-
Save bblum/5751707 to your computer and use it in GitHub Desktop.
trying, so far unsuccessfully, to exploit the lack of a value restriction on lifetime-polymorphic closures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn expect_static(z: &'static int) { | |
} | |
fn foo<'f>(x: @mut Option<&'f fn(&'static int)>, y: &'f fn(&'static int)) { | |
*x = Some(y); | |
} | |
fn bar<'b>(x: @mut Option<&fn(&'b int)>) { | |
let z = 5; | |
match *x { | |
Some(f) => f(&z), | |
None => fail!("oops"), | |
} | |
} | |
fn main() { | |
let a: @mut Option<&fn<'a>(&'a int)> = @mut None; | |
foo(a, expect_static); | |
bar(a); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment