1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
#![crate_name = "gmp"] #![warn(deprecated)] #![allow(non_camel_case_types)] extern crate libc; macro_rules! gen_overloads_inner { ($tr:ident, $meth:ident, $T:ident) => { impl<'a> $tr <&'a $T> for $T { type Output = $T; fn $meth(self, other: &'a $T) -> $T { (&self).$meth(other) } } impl<'a> $tr <$T> for &'a $T { type Output = $T; fn $meth(self, other: $T) -> $T { self.$meth(&other) } } impl $tr<$T> for $T { type Output = $T; fn $meth(self, other: $T) -> $T { (&self).$meth(&other) } } } } macro_rules! gen_overloads { ($T:ident) => { gen_overloads_inner!(Add, add, $T); gen_overloads_inner!(Sub, sub, $T); gen_overloads_inner!(Mul, mul, $T); gen_overloads_inner!(Div, div, $T); impl Neg for $T { type Output = $T; fn neg(self) -> $T { -(&self) } } } } pub mod mpz; pub mod mpq; pub mod mpf; pub mod rand; #[cfg(test)] mod test;