ftracker_identifiers/country/
fmt.rs1use crate::country::CountryCode;
7use core::fmt;
8
9impl fmt::Display for CountryCode {
10 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
11 f.write_str(self.as_str())
12 }
13}
14
15impl fmt::Debug for CountryCode {
16 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17 f.debug_tuple("CountryCode").field(&self.as_str()).finish()
18 }
19}
20
21#[cfg(test)]
22mod tests {
23 use crate::country::CountryCode;
24 use alloc::format;
25 use alloc::string::ToString;
26
27 #[test]
28 fn display_is_the_canonical_string() {
29 let code = CountryCode::parse("US").unwrap();
30 assert_eq!(code.to_string(), "US");
31 }
32
33 #[test]
34 fn debug_is_readable() {
35 let code = CountryCode::parse("US").unwrap();
36 assert_eq!(format!("{code:?}"), "CountryCode(\"US\")");
37 }
38}