use crate::Rational;
use crate::gaussian_rational::GaussianRational;
use malachite_base::num::basic::traits::Zero;
use malachite_nz::gaussian_integer::GaussianInteger;
use malachite_nz::integer::Integer;
use malachite_nz::natural::Natural;
macro_rules! impl_from_purely_real {
($($t: ty),*) => {
$(
impl From<$t> for GaussianRational {
fn from(x: $t) -> Self {
Self {
real: Rational::from(x),
imaginary: Rational::ZERO,
}
}
}
)*
};
}
impl_from_purely_real!(
u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize, bool, Natural, &Natural,
Integer, &Integer, Rational
);
impl From<GaussianInteger> for GaussianRational {
fn from(x: GaussianInteger) -> Self {
Self {
real: Rational::from(x.real),
imaginary: Rational::from(x.imaginary),
}
}
}
impl From<&GaussianInteger> for GaussianRational {
fn from(x: &GaussianInteger) -> Self {
Self {
real: Rational::from(&x.real),
imaginary: Rational::from(&x.imaginary),
}
}
}