Skip to content

Instantly share code, notes, and snippets.

@wtfaremyinitials
Created November 21, 2016 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wtfaremyinitials/f498f415dfee790ff2710c1b91852968 to your computer and use it in GitHub Desktop.
Save wtfaremyinitials/f498f415dfee790ff2710c1b91852968 to your computer and use it in GitHub Desktop.
#[cfg(test)]
mod tests {
fn counter() -> Box<FnMut() -> i32 + 'static> {
let mut b = 0;
let ret = move || { b += 1; b };
Box::new(ret)
}
#[test]
fn it_works() {
let mut count = counter();
assert!(count() == 1);
assert!(count() == 2);
assert!(count() == 3);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment