Add truncate_* operations on BigInt and BigUint#202
Add truncate_* operations on BigInt and BigUint#202digama0 wants to merge 3 commits intorust-num:masterfrom
truncate_* operations on BigInt and BigUint#202Conversation
|
Hi @cuviper, gentle reminder that this PR exists and could use review. |
|
I wonder if there's a way we can do this generically, rather than so many new methods, something like: impl BigUint {
pub fn truncate<T>(&self) -> T
where
T: PrimInt,
u128: AsPrimitive<T>,
{
todo!("truncate as u128").as_()
}
}
impl BigInt {
pub fn truncate<T>(&self) -> T
where
T: PrimInt,
i128: AsPrimitive<T>,
{
todo!("truncate as i128").as_()
}
}The Or maybe |
|
Check out the latest commit for a version that puts all the functions under a trait. It's not It probably shouldn't be merged as is, but if this looks good then the trait should move to the |
Implements rust-num/num#404