pub use const_num_bigint_derive::*;
use const_std_vec::ConstVec;
pub use num_bigint::*;
use std::mem::transmute;
pub struct ConstBigInt {
_sign: Sign,
_data: ConstBigUint,
}
pub struct ConstBigUint {
_data: ConstVec<usize>,
}
impl ConstBigUint {
#[inline]
pub const fn new(arr: &'static [usize]) -> Self {
ConstBigUint {
_data: ConstVec::new(arr),
}
}
#[inline]
pub const fn to_biguint(&'static self) -> &'static BigUint {
unsafe { transmute(self) }
}
}
impl ConstBigInt {
#[inline]
pub const fn new(sign: Sign, arr: &'static [usize]) -> Self {
ConstBigInt {
_sign: sign,
_data: ConstBigUint::new(arr),
}
}
#[inline]
pub const fn to_bigint(&'static self) -> &'static BigInt {
unsafe { transmute(self) }
}
}
#[cfg(target_pointer_width = "64")]
#[macro_export]
macro_rules! from_slice {
($($lo:expr,$hi:expr),*) => {
{
[ $( ($lo) + (($hi)<<32) ),* ]
}
};
( $firstlo:expr $(,$hi:expr,$lo:expr)* ) => {
{
[ ($firstlo) $( + (($hi)<<32) , ($lo) )* ]
}
};
}
#[cfg(target_pointer_width = "32")]
#[macro_export]
macro_rules! from_slice {
( $firstlo:expr $(,$hi:expr,$lo:expr)* ) => {
{
[ ($firstlo) $( , ($hi) , ($lo) )* ]
}
};
($($lo:expr,$hi:expr),*) => {
{
[ $( ($lo) , ($hi) ),* ]
}
};
}
#[macro_export]
macro_rules! bigint {
( $num:expr ) => {
$crate::bigint_with_crate!($crate, $num)
};
}
#[macro_export]
macro_rules! bigint_file {
( $num:expr ) => {
$crate::bigint_file_with_crate!($crate, $num)
};
}
#[macro_export]
macro_rules! biguint {
( $num:expr ) => {
$crate::biguint_with_crate!($crate, $num)
};
}
#[macro_export]
macro_rules! biguint_file {
( $num:expr ) => {
$crate::biguint_file_with_crate!($crate, $num)
};
}