Created
June 6, 2013 17:28
-
-
Save rubber-duck/5723283 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
macro_rules! define_vec ( | |
($vect: ident, $vecmod: ident, $compt: ty, $($components: ident)+) => ( | |
mod $vecmod { | |
#[deriving(ToStr)] | |
pub struct $vect { $($components : $compt),+ } | |
impl $vect | |
{ | |
#[inline(always)] | |
pub fn new($($components: $compt),+) -> $vect { | |
$vect{ $($components: $components),+ } | |
} | |
} | |
} | |
); | |
) | |
define_vec!(Vec3, vec3, f32, x y z) | |
fn main() { | |
let a = vec3::Vec3::new(1.0, 0.0, 0.0); | |
println(fmt!("%?, %?, %?", a.x, a.y, a.z)); | |
} |
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
main.rs:4:23: 4:28 error: conflicting implementations for a trait | |
main.rs:4 #[deriving(ToStr)] | |
^~~~~ | |
main.rs:4:23: 4:28 note: note conflicting implementation here | |
main.rs:4 #[deriving(ToStr)] | |
^~~~~ | |
main.rs:4:23: 4:28 error: conflicting implementations for a trait | |
main.rs:4 #[deriving(ToStr)] | |
^~~~~ | |
main.rs:4:23: 4:28 note: note conflicting implementation here | |
main.rs:4 #[deriving(ToStr)] | |
^~~~~ | |
error: aborting due to 2 previous errors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment