Skip to content

Instantly share code, notes, and snippets.

@jakerr
Last active January 4, 2016 12:19
Show Gist options
  • Save jakerr/8620786 to your computer and use it in GitHub Desktop.
Save jakerr/8620786 to your computer and use it in GitHub Desktop.
struct PositionData {
x: int,
y: int
}
trait Position {
fn position(&self) -> PositionData;
}
trait Color {
fn color(&self) -> int;
}
trait Renderable : Position + Color {}
struct Light {
position: PositionData,
color: int
}
impl Position for Light {
fn position(&self) -> PositionData { self.position }
}
impl Color for Light {
fn color(&self) -> int { self.color }
}
impl Renderable for Light {}
struct PositionData {
x: int,
y: int
}
trait Position {
position: PositionData;
}
trait Color {
color: int;
}
trait Renderable : Position + Color {}
struct Light {
position: PositionData,
color: int
}
impl Renderable for Light {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment