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
#![crate_name = "rust_mpfr"] #![allow(non_camel_case_types)] extern crate libc; extern crate gmp; extern crate rustc_serialize; macro_rules! gen_overloads_inner { ($tr:ident, $meth:ident, $T:ident) => { impl<'a> $tr <$T> for &'a $T { type Output = $T; #[inline] fn $meth(self, other: $T) -> $T { self.$meth(&other) } } impl $tr<$T> for $T { type Output = $T; #[inline] 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); } } #[macro_export] macro_rules! mpfr { ($lit:expr) => { $crate::mpfr::Mpfr::new_from_str(stringify!($lit), 10).expect("Invalid floating point literal") } } pub mod mpfr; #[cfg(test)] mod test;