Skip to content

@bstrie /astrieanna1.rs
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
fn outer1(i: &mut int) {
if *i < 9 {
*i += 1;
outer2(i);
}
}
fn outer2(i: &mut int) {
*i += 1;
outer1(i);
}
fn main() {
let mut foo = 0;
outer1(&mut foo);
io::println(fmt!("%d", foo)); // prints "10"
}
fn main() {
fn outer1(i: &mut int) {
if *i < 9 {
*i += 1;
outer2(i);
}
}
fn outer2(i: &mut int) {
*i += 1;
outer1(i);
}
let mut foo = 0;
outer1(&mut foo);
io::println(fmt!("%d", foo)); // prints "10"
}
fn main() {
let bar = 1;
fn outer1(i: &mut int) {
if *i < 9 {
*i += bar; // error: attempted dynamic environment-capture
outer2(i);
}
}
fn outer2(i: &mut int) {
*i += bar; // error: attempted dynamic environment-capture
outer1(i);
}
let mut foo = 0;
outer1(&mut foo);
io::println(fmt!("%d", foo));
}
fn main() {
let bar = 1;
let outer1 = |i| {
if *i < 9 {
*i += bar;
outer2(i); // error: unresolved name: outer2
}
};
let outer2 = |i| {
*i += bar;
outer1(i);
};
let mut foo = 0;
io::println(fmt!("%d", foo));
outer1(&mut foo);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.