Skip to content

Instantly share code, notes, and snippets.

@olsonjeffery
Created May 18, 2014 19:35
Show Gist options
  • Save olsonjeffery/17ac2b5ad8f5bc054caa to your computer and use it in GitHub Desktop.
Save olsonjeffery/17ac2b5ad8f5bc054caa to your computer and use it in GitHub Desktop.
#[test]
fn an_if_test_that_returns_a_None_out_expr_should_run_the_conseq_branch() {
let mut env = Env::new(
Some(vec!(~"x")), Some(vec!(Atom(Integer(42)))),
None);
let in_expr = parse_str(~"(if (set! x 37) (quote conseq) (quote alt))");
let out_expr = {
let env_borrow = &mut env;
eval(in_expr, env_borrow).expect("should return an Expr")
};
assert_eq!(out_expr, Atom(Symbol(~"conseq")));
assert_eq!(env.find_scope(&~"x").get(&~"x"), &Atom(Integer(37)));
}
src/schemers/main.rs:605:20: 605:23 error: cannot borrow `env` as immutable because it is also borrowed as mutable
src/schemers/main.rs:605 assert_eq!(env.find_scope(&~"x").get(&~"x"), &Atom(Integer(37)));
^~~
<std macros>:1:1: 14:2 note: in expansion of assert_eq!
src/schemers/main.rs:605:9: 605:74 note: expansion site
src/schemers/main.rs:601:30: 601:38 note: previous borrow of `env` occurs here; the mutable borrow prevents subsequent moves, borrows, or modification of `env` until the borrow ends
src/schemers/main.rs:601 let env_borrow = &mut env;
^~~~~~~~
src/schemers/main.rs:606:6: 606:6 note: previous borrow ends here
src/schemers/main.rs:595 fn an_if_test_that_returns_a_None_out_expr_should_run_the_conseq_branch() {
...
src/schemers/main.rs:606 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment