infallible_tobigint

Crates.ioinfallible_tobigint
lib.rsinfallible_tobigint
version0.1.0
sourcesrc
created_at2024-11-20 02:23:12.522618
updated_at2024-11-20 02:23:12.522618
descriptionInfallible ToBigInt/ToBigUint conversion traits for num-bigint
homepagehttps://github.com/Amelit-Nexus/infallible_tobigint
repositoryhttps://github.com/Amelit-Nexus/infallible_tobigint
max_upload_size
id1454212
size28,334
Jonas Weigand (defnotjonas)

documentation

https://docs.rs/infallible_tobigint

README

Infallible ToBigInt

Crates.io Docs.rs CI

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

at your option.

Commit count: 7

cargo fmt