Skip to content

Instantly share code, notes, and snippets.

@MaikKlein
Created June 4, 2013 15:58
Show Gist options
  • Save MaikKlein/5707125 to your computer and use it in GitHub Desktop.
Save MaikKlein/5707125 to your computer and use it in GitHub Desktop.
pub trait BaseVec2<T>{
fn new(x: T, y: T) -> Self;
}
#[deriving(Eq)]
pub struct Vec2<T> { x: T, y: T }
impl<T> BaseVec2<T> for Vec2<T> {
pub fn new(x: T, y: T ) -> Vec2<T> {
Vec2 { x: x, y: y }
}
}
fn main() {
let a = Vec2 { x: 1,y: 2};
let b = Vec2::new(1,2); // doesn't work
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment