Crates.io | factordb |
lib.rs | factordb |
version | 0.3.0 |
source | src |
created_at | 2022-03-31 13:02:10.307324 |
updated_at | 2024-02-05 02:58:41.512924 |
description | Rust wrapper for FactorDB API |
homepage | https://github.com/megascrapper/factordb-rust |
repository | https://github.com/megascrapper/factordb-rust |
max_upload_size | |
id | 559595 |
size | 85,297 |
Rust wrapper for FactorDB API.
Includes a library as well as a simple command line app.
cargo install factordb --all-features
git clone https://github.com/megascrapper/factordb-rust
cd factordb-rust
cargo build --all-features
Rust wrapper for FactorDB API
Usage: factordb [OPTIONS] <NUMBER>
Arguments:
<NUMBER> Number to find its factor
Options:
--unique Print unique factors on each line
--json Print JSON output of FactorDB API
-h, --help Print help
-V, --version Print version
cargo add factordb
use std::error::Error;
use factordb::FactorDbClient;
use num_bigint::BigInt; // All numeric values in the result object are of this type
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
// Initialise the client
let client = FactorDbClient::new();
// Make requests
let forty_two = client.get(42).await?;
let expect_factors: Vec<BigInt> = vec![2, 3, 7].into_iter().map(|n| BigInt::from(n)).collect();
assert_eq!(forty_two.into_factors_flattened(), expect_factors);
Ok(())
}
https://docs.rs/factordb/latest/factordb/
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.