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\")");
}
}