pub use from_ref::*;
use std::convert::From;
use crate::prim::{typ::*, mpz::*, mpf::*, mpq::*};
from_ref_mut_unop!{impl From, from for mpz_s, mpz_s}
impl<'a> From<&'a mpz_s> for mpz_s {
#[inline]
fn from(a: &'a mpz_s) -> Self {
mpz_s::init_set(a)
}
}
impl From<ui_t> for mpz_s {
#[inline]
fn from(u: ui_t) -> Self {
mpz_s::init_set_ui(u)
}
}
impl From<si_t> for mpz_s {
#[inline]
fn from(s: si_t) -> Self {
mpz_s::init_set_si(s)
}
}
impl From<double_t> for mpz_s {
#[inline]
fn from(d: double_t) -> Self {
mpz_s::init_set_d(d)
}
}
impl<'a> From<&'a str> for mpz_s {
#[inline]
fn from(s: &'a str) -> Self {
mpz_s::init_set_str(s, 10)
}
}
from_ref_mut_unop!{impl From, from for mpf_s, mpf_s}
impl<'a> From<&'a mpf_s> for mpf_s {
#[inline]
fn from(f: &'a mpf_s) -> Self {
mpf_s::init_set(f)
}
}
impl From<ui_t> for mpf_s {
#[inline]
fn from(u: ui_t) -> Self {
mpf_s::init_set_ui(u)
}
}
impl From<si_t> for mpf_s {
#[inline]
fn from(s: si_t) -> Self {
mpf_s::init_set_si(s)
}
}
impl From<double_t> for mpf_s {
#[inline]
fn from(d: double_t) -> Self {
mpf_s::init_set_d(d)
}
}
impl<'a> From<&'a str> for mpf_s {
#[inline]
fn from(s: &'a str) -> Self {
mpf_s::init_set_str(s, 10)
}
}
from_ref_unop!{impl From, from for mpf_s, mpz_s}
impl<'a> From<&'a mpz_s> for mpf_s {
#[inline]
fn from(a: &'a mpz_s) -> Self {
mpf_s::init_set_z(a)
}
}
from_ref_unop!{impl From, from for mpf_s, mpq_s}
impl<'a> From<&'a mpq_s> for mpf_s {
#[inline]
fn from(q: &'a mpq_s) -> Self {
mpf_s::init_set_q(q)
}
}
from_ref_mut_unop!{impl From, from for mpq_s, mpq_s}
impl<'a> From<&'a mpq_s> for mpq_s {
#[inline]
fn from(q: &'a mpq_s) -> Self {
let mut t = mpq_s::init();
t.set(q);
t
}
}
impl From<(ui_t, ui_t)> for mpq_s {
#[inline]
fn from((p, q): (ui_t, ui_t)) -> Self {
let mut t = mpq_s::init();
t.set_ui((p, q));
t
}
}
impl From<(si_t, ui_t)> for mpq_s {
#[inline]
fn from((p, q): (si_t, ui_t)) -> Self {
let mut t = mpq_s::init();
t.set_si((p, q));
t
}
}
impl From<double_t> for mpq_s {
#[inline]
fn from(d: double_t) -> Self {
let mut t = mpq_s::init();
t.set_d(d);
t
}
}
impl<'a> From<&'a str> for mpq_s {
#[inline]
fn from(s: &'a str) -> Self {
let mut t = mpq_s::init();
t.set_str(s, 10);
t
}
}
from_ref_unop!{impl From, from for mpq_s, mpz_s}
impl<'a> From<&'a mpz_s> for mpq_s {
#[inline]
fn from(a: &'a mpz_s) -> Self {
let mut t = mpq_s::init();
t.set_z(a);
t
}
}
from_ref_unop!{impl From, from for mpq_s, mpf_s}
impl<'a> From<&'a mpf_s> for mpq_s {
#[inline]
fn from(f: &'a mpf_s) -> Self {
let mut t = mpq_s::init();
t.set_f(f);
t
}
}
impl<'a, 'b> From<(&'a mpz_s, &'b mpz_s)> for mpq_s {
#[inline]
fn from((p, q): (&'a mpz_s, &'b mpz_s)) -> Self {
mpq_s::frac(p, q)
}
}