ftracker-identifiers 0.0.2

Validated, no_std-first identifier types: CNPJ, ISIN, CFI, and ISO 3166-1 country codes.
Documentation
//! `Display` and `Debug` for [`CountryCode`].
//!
//! A country code has no punctuated form. Its canonical rendering is the compact two letter string,
//! which [`CountryCode::as_str`](CountryCode::as_str) already returns.

use crate::country::CountryCode;
use core::fmt;

impl fmt::Display for CountryCode {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        f.write_str(self.as_str())
    }
}

impl fmt::Debug for CountryCode {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        f.debug_tuple("CountryCode").field(&self.as_str()).finish()
    }
}

#[cfg(test)]
mod tests {
    use crate::country::CountryCode;
    use alloc::format;
    use alloc::string::ToString;

    #[test]
    fn display_is_the_canonical_string() {
        let code = CountryCode::parse("US").unwrap();
        assert_eq!(code.to_string(), "US");
    }

    #[test]
    fn debug_is_readable() {
        let code = CountryCode::parse("US").unwrap();
        assert_eq!(format!("{code:?}"), "CountryCode(\"US\")");
    }
}