Skip to content

Instantly share code, notes, and snippets.

View sdleffler's full-sized avatar

Shea Leffler sdleffler

View GitHub Profile
static inline void wv_2d_constrain(wave_2d_t* wave, state_2d_t* focus, bool* update_focus, state_2d_t* subject, bool* update_subject) {
int32_t sx = (((int32_t)subject->x) - ((int32_t)focus->x)) % wave->width;
if (sx > (int32_t)wave->width / 2) sx -= wave->width;
if (sx < -(int32_t)wave->width / 2) sx += wave->width;
int32_t sy = (((int32_t)subject->y) - ((int32_t)focus->y)) % wave->height;
if (sy > (int32_t)wave->height / 2) sy -= wave->height;
if (sy < -(int32_t)wave->height / 2) sy += wave->height;
debug_assertf(abs(sx) < wave->source->n && abs(sy) < wave->source->n,
"Delta-x/delta-y should have absolute values of less than n! dx: %i, dy: %i, n: %u.", sx, sy, wave->source->n);
use std::marker::PhantomData;
mod arith;
pub use self::arith::*;
pub trait Nat {
fn as_usize() -> usize;
}
use std;
use std::ops::{Deref, DerefMut};
use std::slice;
use peano::*;
#[macro_export]
macro_rules! pairs {
($elem:expr $(, $rest:expr)*) => ($crate::array::storage::Pair { l: $elem, r: pairs!($($rest),*) });
= note: expected type `fn(&[geometry::primitive::Point<T, D>]) -> std::vec::Vec<geometry::primitive::Facet<T, D>>`
= note: found type `fn(&'a [geometry::primitive::Point<T, D>]) -> std::vec::Vec<geometry::primitive::Facet<T, D>>`
= note: the anonymous lifetime #1 defined on unknown free region bounded by scope CodeExtent(15851/CallSiteScope { fn_id: NodeId(14015), body_id: NodeId(27848) })...
= note: ...does not necessarily outlive the lifetime 'a as defined on unknown free region bounded by scope CodeExtent(15851/CallSiteScope { fn_id: NodeId(14015), body_id: NodeId(27848) })
impl<T: Clone + Scalar + Float + From<f64>, A, B> GjkExt<B> for A
where A: SupportMapping<Scalar = T>,
B: SupportMapping<Scalar = T, Dims = A::Dims>,
A::Dims: Size<T>,
<A::Dims as Dim>::Succ: Size<Vect<T, A::Dims>> + Size<Point<T, A::Dims>> + DimMul<<A::Dims as Dim>::Succ>,
<<A::Dims as Dim>::Succ as DimMul<<A::Dims as Dim>::Succ>>::Result: Size<T>,
I: DimShl<<A::Dims as Dim>::Succ>,
<I as DimShl<<A::Dims as Dim>::Succ>>::Result: DimMul<<A::Dims as Dim>::Succ>,
<<I as DimShl<<A::Dims as Dim>::Succ>>::Result as DimMul<<A::Dims as Dim>::Succ>>::Result: Size<T>
{
sean@sean-Samus:~/Projects/faster-sort$ cargo bench
Finished release [optimized] target(s) in 0.0 secs
Running target/release/deps/faster_sort-5d319d373e6d360c
running 21 tests
test tests::test ... ignored
test tests::new_sort_ascending ... bench: 52,921 ns/iter (+/- 1,924) = 755 MB/s
test tests::new_sort_big_ascending ... bench: 130,940 ns/iter (+/- 69,309) = 2443 MB/s
test tests::new_sort_big_descending ... bench: 130,313 ns/iter (+/- 64,020) = 2455 MB/s
test tests::new_sort_big_random_large ... bench: 2,735,334 ns/iter (+/- 1,171,611) = 116 MB/s
...
//! # The DSL
//!
//! Let's take a look at this fairly small example:
//! ```rust
//! # #[macro_use] extern crate type_operators;
//! type_operators! {
//! [A, B, C, D, E]
//!
//! data Nat {
Worker information
hostname: i-2a434dd2-precise-production-2-worker-org-docker.travisci.net:a028cb53-86dc-472f-916d-6594a4335c69
version: v2.5.0-8-g19ea9c2 https://github.com/travis-ci/worker/tree/19ea9c20425c78100500c7cc935892b47024922c
instance: 6c5b114:travis:default
startup: 535.476581ms
Build system information
Build language: rust
Build group: stable
Build dist: precise
Build id: 180792452
impl<'a, P: Pattern> Pattern for &'a [P] {
type BindIter = iter::FlatMap<slice::Iter<'a, P>, P::BindIter, fn(&P) -> P::BindIter>;
type PatFvIter = iter::FlatMap<slice::Iter<'a, P>, P::PatFvIter, fn(&P) -> P::PatFvIter>;
fn pattern_binders(&self) -> Self::BindIter {
self.iter().flat_map(P::pattern_binders)
}
fn pattern_free_vars(&self) -> Self::PatFvIter {
self.iter().flat_map(P::pattern_free_vars)
@sdleffler
sdleffler / rust-smallfuck-concretes.rs
Last active March 11, 2017 14:54
`type_operators!` concrete definitions for the `tarpit-rs` Rust type-level Smallfuck interpreter.
// `Bit` trait and `T` and `F` types.
pub trait Bit {
fn reify() -> bool;
}
pub struct F;
pub struct T;