![Build status] ![Latest version] ![Documentation]
Parse and generate random CPF/ICN and CNPJ, Brazil's ID numbers.
First, add the following to your Cargo.toml
:
toml
[dependencies]
brids = "0.1"
Next, add this to your crate root:
rust
extern crate brids;
Parse and format:
```rust extern crate brids;
use brids::Cpf; use std::io::{stdin, stdout, Write};
fn main() { print!("Input a CPF number: "); stdout().flush().ok();
let mut input = String::with_capacity(14);
stdin().read_line(&mut input).ok();
match input.trim().parse::<Cpf>() {
Ok(cpf) => println!("{} is a valid CPF number.", cpf),
Err(_) => println!("Invalid number."),
}
} ```
Generate random CNPJ and CPF/ICN numbers:
```rust extern crate brids;
use brids::{Cnpj, Cpf};
fn main() { println!("Random CNPJ number: {}", Cnpj::generate()); println!("Random CPF number: {}", Cpf::generate()); } ```
brids
is licensed under either of the following, at your option: