Struct cnpj::Cnpj [−][src]
pub struct Cnpj { /* fields omitted */ }
Expand description
A valid CNPJ number.
Initialize a Cnpj
from a &str
or an array of digits:
use cnpj::Cnpj; let cnpj = "96.769.900/0001-77".parse::<Cnpj>()?; assert_eq!(cnpj.digits(), [9, 6, 7, 6, 9, 9, 0, 0, 0, 0, 0, 1, 7, 7]);
Note that the Cnpj
struct can only be initialized after a successfully parse,
so it is guaranteed to always be valid.
use cnpj::Cnpj; let cnpj = "00.000.000/0000-00".parse::<Cnpj>(); assert!(cnpj.is_err()); let cnpj = "96.769.900/0001-77".parse::<Cnpj>().unwrap(); assert!(cnpj::valid(cnpj));
Implementations
The Cnpj digits.
use cnpj::Cnpj; let cnpj: Cnpj = "96.769.900/0001-77".parse()?; assert_eq!(cnpj.digits(), [9, 6, 7, 6, 9, 9, 0, 0, 0, 0, 0, 1, 7, 7]);
Returns the (unformatted) CNPJ number.
use cnpj::Cnpj; let cnpj: Cnpj = "96.769.900/0001-77".parse()?; assert_eq!(cnpj.as_str(), "96769900000177");
Note that even being unformatted, the number will be padded by zeros.
use cnpj::Cnpj; let cnpj: Cnpj = "1219900000197".parse()?; assert_eq!(cnpj.as_str(), "01219900000197");
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Cnpj
impl UnwindSafe for Cnpj
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V