rust_mpfr/
lib.rs

1#![crate_name = "rust_mpfr"]
2#![allow(non_camel_case_types)]
3
4extern crate libc;
5extern crate gmp;
6extern crate rustc_serialize;
7
8macro_rules! gen_overloads_inner {
9    ($tr:ident, $meth:ident, $T:ident) => {
10        impl<'a> $tr <$T> for &'a $T {
11            type Output = $T;
12            #[inline]
13            fn $meth(self, other: $T) -> $T {
14                self.$meth(&other)
15            }
16        }
17        impl $tr<$T> for $T {
18            type Output = $T;
19            #[inline]
20            fn $meth(self, other: $T) -> $T {
21                self.$meth(&other)
22            }
23        }
24    }
25}
26
27macro_rules! gen_overloads {
28    ($T:ident) => {
29        gen_overloads_inner!(Add, add, $T);
30        gen_overloads_inner!(Sub, sub, $T);
31        gen_overloads_inner!(Mul, mul, $T);
32        gen_overloads_inner!(Div, div, $T);
33    }
34}
35
36#[macro_export]
37macro_rules! mpfr {
38    ($lit:expr) => {
39        $crate::mpfr::Mpfr::new_from_str(stringify!($lit), 10).expect("Invalid floating point literal")
40    }
41}
42
43pub mod mpfr;
44
45#[cfg(test)]
46mod test;