Skip to content

Instantly share code, notes, and snippets.

@blt
Created March 31, 2016 22:38
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 blt/71dbfa9748fa185dec1e506ba9000da0 to your computer and use it in GitHub Desktop.
Save blt/71dbfa9748fa185dec1e506ba9000da0 to your computer and use it in GitHub Desktop.
#![cfg_attr(test, feature(plugin))]
#![cfg_attr(test, plugin(quickcheck_macros))]
#[cfg(test)]
extern crate quickcheck;
fn reverse<T: Clone>(xs: &[T]) -> Vec<T> {
let mut rev = vec!();
for x in xs {
rev.insert(0, x.clone())
}
rev
}
#[cfg(test)]
mod tests {
#[quickcheck]
fn double_reversal_is_identity(xs: Vec<isize>) -> bool {
xs == super::reverse(&super::reverse(&xs))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment