Crates.io | infallible_tobigint |
lib.rs | infallible_tobigint |
version | 0.1.0 |
source | src |
created_at | 2024-11-20 02:23:12.522618 |
updated_at | 2024-11-20 02:23:12.522618 |
description | Infallible ToBigInt/ToBigUint conversion traits for num-bigint |
homepage | https://github.com/Amelit-Nexus/infallible_tobigint |
repository | https://github.com/Amelit-Nexus/infallible_tobigint |
max_upload_size | |
id | 1454212 |
size | 28,334 |
This crate provides to traits InfallibleToBigInt
and InfallibleToBigUint
. They provide the to_bigint(&self)
and
to_biguint(&self)
from the popular num-bigint
crate. But they are only
implemented on types that support infallible conversion, and so they do not return a Result
but only
BigInt
/BigUint
. This results in cleaner code.
cargo install infallible_tobigint
use crate::infallible_to_big_int::*;
// use the conversion directly
153830.to_bigint();
// or define a function which takes any InfallibleToBigInt
fn do_great_things(to_bigint: impl InfallibleToBigInt) {
let bigint = to_bigint.to_bigint();
// ... do something nice with bigint here
}
// then you can call it like this
do_great_things(153830)
Licensed under either of
at your option.