Created
April 4, 2013 22:21
-
-
Save nikomatsakis/5314896 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub trait BaseVec: Index<uint,Self::T> | |
+ Eq { | |
type T; | |
static LEN: uint; | |
fn from_value(value: Self::T) -> Self; | |
} | |
pub trait BaseVec3: BaseVec { | |
fn new(x: Self::T, y: Self::T, z: Self::T) -> Self; | |
} | |
pub trait NumVec: BaseVec | |
+ Neg<Self> { | |
static IDENT: Self; | |
static ZERO: Self; | |
} | |
pub trait NumVec3: BaseVec | |
+ NumVec { | |
static UNIT_X: Self; | |
static UNIT_Y: Self; | |
static UNIT_Z: Self; | |
} | |
#[deriving(Eq)] | |
pub struct Vec3<T> { x: T, y: T, z: T } | |
type Vec3f = Vec3<float> | |
impl<T:Copy> BaseVec for Vec3<T> { | |
type T = T; | |
static LEN: uint = 3; | |
fn from_value(value: T) -> Vec3<T> { | |
Vec3 { x: value, y: value, z: value } | |
} | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment