1 unstable release
0.1.0 | Nov 20, 2024 |
---|
#1173 in Math
150 downloads per month
17KB
329 lines
Infallible ToBigInt
Overview
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.
Installation
Cargo
- Install the rust toolchain in order to have cargo installed by following this guide.
- run
cargo install infallible_tobigint
Usage
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)
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Dependencies
~465KB