Skip to content

Instantly share code, notes, and snippets.

@blt blt/reverse.rs
Created Mar 31, 2016

Embed
What would you like to do?
#![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
You can’t perform that action at this time.