Skip to content

Instantly share code, notes, and snippets.

@yamafaktory
Last active January 24, 2019 22:22
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 yamafaktory/38c2f54b0b94faebfd790783150c3d1a to your computer and use it in GitHub Desktop.
Save yamafaktory/38c2f54b0b94faebfd790783150c3d1a to your computer and use it in GitHub Desktop.
#![feature(test)]
extern crate test;
pub fn minus_one(number: i32) -> i32 {
number - 1
}
#[cfg(test)]
mod tests {
use super::*;
use test::Bencher;
#[test]
fn test_minus_one() {
assert_eq!(minus_one(1), 0);
}
#[bench]
fn bench_minus_one(b: &mut Bencher) {
b.iter(|| minus_one(1));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment