cnpj-rs
Brazilian CNPJ parsing, validating and formatting library.
use Cnpj;
// Use the `valid` function if all you need is validating a CNPJ number
assert!;
assert!;
assert!;
// Parse into a Cnpj struct if you need formatting or other metadata
let cnpj: Cnpj = "96769900000177".parse?;
assert_eq!;
assert_eq!;
// Note that the Cnpj struct is guaranteed to always be valid
assert!;
assert!;
no_std support
The library makes no dinamic allocation and can be used on no_std
environments by disabling the std
flag:
[]
= { = "0.2", = false }
Random CNPJ generation support
The rand
feature flag enables random CNPJ generation:
[]
= { = "0.2", = ["rand"] }
= "0.8"
use Cnpj;
use rand;
use Rng;
let cnpj: Cnpj = thread_rng.gen;