Skip to content

Instantly share code, notes, and snippets.

View jnordwick's full-sized avatar
🏝️
Wilson!!!

Jason Nordwick jnordwick

🏝️
Wilson!!!
  • Black Sheep Capital
  • Brooklyn, NY
  • 13:21 (UTC -04:00)
View GitHub Profile
@jnordwick
jnordwick / gist:26acb66d05385d03795b
Created July 24, 2015 22:30
Rust nightly from 7/24/15 loop tests
jason@mintyfresh ~/rdev/rloop/src $ rustc --version
rustc 1.3.0-dev (5e6b53436 2015-07-24)
jason@mintyfresh ~/rdev/rloop/src $ cargo bench --verbose
Fresh rloop v0.1.0 (file:///home/jason/rdev/rloop)
Running `/home/jason/rdev/rloop/target/release/rloop-30eefaffa210e640 --bench`
running 16 tests
test extend1 ... bench: 1,043 ns/iter (+/- 79)
test extend2 ... bench: 1,049 ns/iter (+/- 60)
test extend_vecdeque1 ... bench: 1,069 ns/iter (+/- 10)
@jnordwick
jnordwick / gist:a01ce25acc8c13b4da34
Created July 24, 2015 22:31
stupid enum tricks
#[derive(Debug)]
enum List<T,L> {
Null(T),
Cell(T,L),
}
use List::*;
type Nil<T> = List<T,()>;
type Single<T> = List<T,Nil<T>>;
@jnordwick
jnordwick / avg.rs
Created July 30, 2015 22:13
count, sum, and avg macros in rust
macro_rules! avg {
($($t:expr),*) => (sum!($($t),*)/count!($($t),*));
}
macro_rules! count {
($h:expr) => (1);
($h:expr, $($t:expr),*) =>
(1 + count!($($t),*));
}