Skip to content

Instantly share code, notes, and snippets.

@rubber-duck
Created June 6, 2013 17:28
Show Gist options
  • Save rubber-duck/5723283 to your computer and use it in GitHub Desktop.
Save rubber-duck/5723283 to your computer and use it in GitHub Desktop.
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));
}
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