Skip to content

Instantly share code, notes, and snippets.

@brson
Created December 4, 2012 02:09
Show Gist options
  • Save brson/4199903 to your computer and use it in GitHub Desktop.
Save brson/4199903 to your computer and use it in GitHub Desktop.
fn main() {
let id: &Mat2<float> = &Matrix::identity();
}
pub trait Index<Index,Result> { }
pub trait Dimensional<T>: Index<uint, T> { }
pub struct Mat2<T> { x: () }
pub struct Vec2<T> { x: () }
pub impl<T> Mat2<T>: Dimensional<Vec2<T>> { }
pub impl<T> Mat2<T>: Index<uint, Vec2<T>> { }
pub impl<T> Vec2<T>: Dimensional<T> { }
pub impl<T> Vec2<T>: Index<uint, T> { }
pub trait Matrix<T,V>: Dimensional<V> {
static pure fn identity() -> self;
}
pub impl<T> Mat2<T>: Matrix<T, Vec2<T>> {
static pure fn identity() -> Mat2<T> { fail }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment