celes/
tables.rs

1use core::cmp::Ordering;
2use core::{fmt, slice::Iter};
3use serde::{
4    Deserialize, Deserializer, Serialize, Serializer,
5    de::{SeqAccess, Visitor},
6    ser::SerializeTuple,
7};
8
9macro_rules! lookup {
10    (@gen [$doc:expr, $name:ident, $enum:ident, $len:expr, $($aliases:expr => $loweralias:expr),+]) => {
11        #[doc = $doc]
12        #[derive(Copy, Clone, Eq, Ord)]
13        pub struct $name(pub [&'static str; $len]);
14
15        impl $name {
16            pub(crate) const fn const_default() -> Self {
17                Self([$($aliases,)*])
18            }
19
20            pub(crate) const fn into_country_table(self) -> CountryTable {
21                CountryTable::$enum(self)
22            }
23        }
24
25        impl Default for $name {
26            fn default() -> Self {
27                Self::const_default()
28            }
29        }
30
31        impl LookupTable for $name {
32            fn contains(&self, alias: &str) -> bool {
33                match alias.to_lowercase().as_str() {
34                    $($loweralias => true,)*
35                    _ => false
36                }
37            }
38
39            fn len(&self) -> usize {
40                self.0.len()
41            }
42
43            fn iter(&self) -> Iter<'_, &'static str> {
44                self.0.iter()
45            }
46        }
47
48        impl Serialize for $name {
49            fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
50                where S: Serializer
51            {
52                let mut seq = s.serialize_tuple(self.0.len())?;
53                for e in &self.0 {
54                    seq.serialize_element(e)?;
55                }
56                seq.end()
57            }
58        }
59
60        impl<'de> Deserialize<'de> for $name {
61            fn deserialize<D>(deserializer: D) -> Result<$name, D::Error>
62                where D: Deserializer<'de>
63            {
64                struct TableVisitor;
65                impl<'de> Visitor<'de> for TableVisitor {
66                    type Value = $name;
67
68                    fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
69                        write!(f, "an array of strings")
70                    }
71
72                    fn visit_seq<A>(self, _seq: A) -> Result<$name, A::Error>
73                        where A: SeqAccess<'de>
74                    {
75                        // // for i in 0..$len {
76                        //     let _ = seq.next_element()?.ok_or_else(|| DError::invalid_length(i, &self))?;
77                        // }
78                        Ok($name::default())
79                    }
80                }
81
82                deserializer.deserialize_tuple($len, TableVisitor)
83            }
84        }
85
86        impl From<$name> for CountryTable {
87            fn from(n: $name) -> Self {
88                n.into_country_table()
89            }
90        }
91
92        impl<L: LookupTable> PartialOrd<L> for $name {
93            fn partial_cmp(&self, other: &L) -> Option<Ordering> {
94                if self.len() == other.len() {
95                    let mut res = None;
96                    for (l, r) in self.iter().zip(other.iter()) {
97                        res = l.partial_cmp(r);
98                        match res {
99                            Some(Ordering::Equal) | None => {},
100                            _ => break,
101                        }
102                    }
103                    res
104                } else {
105                    self.len().partial_cmp(&other.len())
106                }
107            }
108        }
109
110        impl<L: LookupTable> PartialEq<L> for $name {
111            fn eq(&self, other: &L) -> bool {
112                self.len() == other.len() &&
113                self.iter().zip(other.iter()).all(|(l, r)| *l == *r)
114            }
115        }
116
117        impl core::hash::Hash for $name {
118            fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
119                for s in self.iter() {
120                    s.hash(state);
121                }
122            }
123        }
124
125        impl fmt::Display for $name {
126            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
127                write!(f, "[{}]", self.0.join(","))
128            }
129        }
130
131        impl fmt::Debug for $name {
132            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
133                write!(f, "{} - [{}]", stringify!($name), self.0.join(","))
134            }
135        }
136    };
137    ($name:ident, $enum:ident, $long_name:expr, $len:expr, $($aliases:expr => $loweralias:expr),+) => {
138        lookup! { @gen [concat!("Aliases for ", stringify!($long_name)), $name, $enum, $len, $( $aliases => $loweralias ),* ]}
139    };
140}
141
142/// A lookup table where all elements are statically known
143pub trait LookupTable {
144    /// True if this lookup table contains `alias`
145    fn contains(&self, alias: &str) -> bool;
146    /// The number of elements in this lookup table
147    fn len(&self) -> usize;
148    /// True if there are no elements
149    fn is_empty(&self) -> bool {
150        self.len() == 0
151    }
152    /// An iterator over this lookup table
153    fn iter(&self) -> Iter<'_, &'static str>;
154}
155
156/// Since reference for the EmptyLookupTable
157pub const EMPTY_LOOKUP_TABLE: EmptyLookupTable = EmptyLookupTable([]);
158
159/// A lookup table with zero entries
160#[derive(Copy, Clone, Default, Serialize, Deserialize, Eq, Ord)]
161pub struct EmptyLookupTable(pub [&'static str; 0]);
162
163impl EmptyLookupTable {
164    pub(crate) const fn into_country_table(self) -> CountryTable {
165        CountryTable::Empty(self)
166    }
167}
168
169impl LookupTable for EmptyLookupTable {
170    fn contains(&self, _: &str) -> bool {
171        false
172    }
173
174    fn len(&self) -> usize {
175        0
176    }
177
178    fn iter(&self) -> Iter<'_, &'static str> {
179        [].iter()
180    }
181}
182
183impl<L: LookupTable> PartialEq<L> for EmptyLookupTable {
184    fn eq(&self, other: &L) -> bool {
185        self.len() == other.len() && self.iter().zip(other.iter()).all(|(l, r)| *l == *r)
186    }
187}
188
189impl<L: LookupTable> PartialOrd<L> for EmptyLookupTable {
190    fn partial_cmp(&self, other: &L) -> Option<Ordering> {
191        if other.len() > 0 {
192            Some(Ordering::Greater)
193        } else {
194            Some(Ordering::Equal)
195        }
196    }
197}
198
199impl From<EmptyLookupTable> for CountryTable {
200    fn from(t: EmptyLookupTable) -> Self {
201        t.into_country_table()
202    }
203}
204
205impl fmt::Display for EmptyLookupTable {
206    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
207        write!(f, "[]")
208    }
209}
210
211impl fmt::Debug for EmptyLookupTable {
212    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
213        write!(f, "EmptyLookupTable")
214    }
215}
216
217lookup!(SamoaTable, Samoa, "American Samoa", 1, "Samoa" => "samoa");
218lookup!(SaintHelenaTable, SaintHelena, "Ascension And Tristan Da Cunha Saint Helena", 2, "StHelena" => "sthelena", "SaintHelena" => "sainthelena");
219lookup!(VenezuelaTable, Venezuela, "Bolivarian Republic Of Venezuela", 1, "Venezuela" => "venezuela");
220lookup!(BosniaTable, Bosnia, "Bosnia And Herzegovina", 2, "Bosnia" => "bosnia", "Herzegovina" => "herzegovina");
221lookup!(BruneiTable, Brunei, "Brunei Darussalam", 1, "Brunei" => "brunei");
222lookup!(BurkinaTable, Burkina, "Burkina Faso", 1, "Burkina" => "burkina");
223lookup!(StMaartenTable, StMaarten, "Dutch Part Sint Maarten", 2, "StMaarten" => "stmaarten", "SaintMaarten" => "saintmaarten");
224lookup!(MicronesiaTable, Micronesia, "Federated States Of Micronesia", 1, "Micronesia" => "micronesia");
225lookup!(StMartinTable, StMartin, "French Part Saint Martin", 2, "StMartin" => "stmartin", "SaintMartin" => "saintmartin");
226lookup!(HeardIslandTable, HeardIsland, "Heard Island And Mc Donald Islands", 2, "HeardIsland" => "heardisland", "McDonaldIslands" => "mcDonaldislands");
227lookup!(IranTable, Iran, "Islamic Republic Of Iran", 1, "Iran" => "iran");
228lookup!(MacedoniaTable, Macedonia, "Republic Of North Macedonia", 1, "Macedonia" => "macedonia");
229lookup!(StBarthelemyTable, StBarthelemy, "Saint Barthelemy", 1, "StBarthelemy" => "stbarthelemy");
230lookup!(StKittsTable, StKitts, "Saint Kitts And Nevis", 1, "StKitts" => "stkitts");
231lookup!(StLuciaTable, StLucia, "Saint Lucia", 1, "StLucia" => "stlucia");
232lookup!(StPierreTable, StPierre, "Saint Pierre And Miquelon", 2, "StPierre" => "stpierre", "SaintPierre" => "saintpierre");
233lookup!(StVincentTable, StVincent, "Saint Vincent And The Grenadines", 2, "StVincent" => "stvincent", "SaintVincent" => "saintvincent");
234lookup!(SaoTomeTable, SaoTome, "Sao Tome And Principe", 1, "SaoTome" => "saotome");
235lookup!(SouthGeorgiaTable, SouthGeorgia, "South Georgia And The South Sandwich Islands", 2, "SouthGeorgia" => "southgeorgia", "SouthSandwichIslands" => "southsandwichislands");
236lookup!(PalestineTable, Palestine, "State Of Palestine", 1, "Palestine" => "palestine");
237lookup!(TaiwanTable, Taiwan, "Taiwan Province Of China", 1, "Taiwan" => "taiwan");
238lookup!(BahamasTable, Bahamas, "The Bahamas", 1, "Bahamas" => "bahamas");
239lookup!(CaymanIslandsTable, CaymanIslands, "The Cayman Islands", 1, "CaymanIslands" => "caymanislands");
240lookup!(CentralAfricanRepublicTable, CentralAfricanRepublic, "The Central African Republic", 1, "CentralAfricanRepublic" => "centralafricanrepublic");
241lookup!(CocosIslandsTable, CocosIslands, "The Cocos Keeling Islands", 2, "CocosIslands" => "cocosislands", "KeelingIslands" => "keelingislands");
242lookup!(ComorosTable, Comoros, "The Comoros", 1, "Comoros" => "comoros");
243lookup!(CongoTable, Congo, "The Congo", 1, "Congo" => "congo");
244lookup!(CookIslandsTable, CookIslands, "The Cook Islands", 1, "CookIslands" => "cookislands");
245lookup!(NorthKoreaTable, NorthKorea, "The Democratic Peoples Republic Of Korea", 2, "NorthKorea" => "northkorea", "DemocraticPeoplesRepublicOfKorea" => "democraticpeoplesrepublicofkorea");
246lookup!(DemocraticRepublicOfTheCongoTable, DemocraticRepublicOfTheCongo, "The Democratic Republic Of The Congo", 1, "DemocraticRepublicOfTheCongo" => "democraticrepublicofthecongo");
247lookup!(DominicanRepublicTable, DominicanRepublic, "The Dominican Republic", 1, "DominicanRepublic" => "dominicanrepublic");
248lookup!(MalvinasTable, Malvinas, "The Falkland Islands Malvinas", 2, "Malvinas" => "malvinas", "FalklandIslands" => "falklandislands");
249lookup!(FaroeIslandsTable, FaroeIslands, "The Faroe Islands", 1, "FaroeIslands" => "faroeislands");
250lookup!(FrenchSouthernTerritoriesTable, FrenchSouthernTerritories, "The French Southern Territories", 1, "FrenchSouthernTerritories" => "frenchsouthernterritories");
251lookup!(GambiaTable, Gambia, "The Gambia", 1, "Gambia" => "gambia");
252lookup!(HolySeeTable, HolySee, "The Holy See", 1, "HolySee" => "holysee");
253lookup!(LaoPeoplesDemocraticRepublicTable, LaoPeoplesDemocraticRepublic, "The Lao Peoples Democratic Republic", 1, "LaoPeoplesDemocraticRepublic" => "laopeoplesdemocraticrepublic");
254lookup!(MarshallIslandsTable, MarshallIslands, "The Marshall Islands", 1, "MarshallIslands" => "marshallislands");
255lookup!(NetherlandsTable, Netherlands, "The Netherlands", 2, "Netherlands" => "netherlands", "Holland" => "holland");
256lookup!(NigerTable, Niger, "The Niger", 1, "Niger" => "niger");
257lookup!(NorthernMarianaIslandsTable, NorthernMarianaIslands, "The Northern Mariana Islands", 1, "NorthernMarianaIslands" => "northernmarianaislands");
258lookup!(PhilippinesTable, Philippines, "The Philippines", 1, "Philippines" => "philippines");
259lookup!(SouthKoreaTable, SouthKorea, "The Republic Of Korea", 2, "SouthKorea" => "southkorea", "RepublicOfKorea" => "republicofkorea");
260lookup!(MoldovaTable, Moldova, "The Republic Of Moldova", 2, "Moldova" => "moldova", "RepublicOfMoldova" => "republicofmoldova");
261lookup!(RussiaTable, Russia, "The Russian Federation", 2, "Russia" => "russia", "RussianFederation" => "russianfederation");
262lookup!(SudanTable, Sudan, "The Sudan", 1, "Sudan" => "sudan");
263lookup!(TurksAndCaicosIslandsTable, TurksAndCaicosIslands, "The Turks And Caicos Islands", 1, "TurksAndCaicosIslands" => "turksandcaicosislands");
264lookup!(UnitedArabEmiratesTable, UnitedArabEmirates, "The United Arab Emirates", 1, "UnitedArabEmirates" => "unitedarabemirates");
265lookup!(EnglandTable, England, "The United Kingdom Of Great Britain And Northern Ireland", 7, "England" => "england",
266        "Scotland" => "scotland",
267        "GreatBritain" => "greatbritain",
268        "UnitedKingdom" => "unitedkingdom",
269        "NorthernIreland" => "northernireland",
270        "UnitedKingdomOfGreatBritain" => "unitedkingdomofgreatbritain",
271        "UnitedKingdomOfGreatBritainAndNorthernIreland" => "unitedkingdomofgreatbritainandnorthernireland");
272lookup!(UnitedStatesMinorOutlyingIslandsTable, UnitedStatesMinorOutlyingIslands, "The United States Minor Outlying Islands", 1, "UnitedStatesMinorOutlyingIslands" => "unitedstatesminoroutlyingislands");
273lookup!(AmericaTable, America, "The United States Of America", 3, "America" => "america", "UnitedStates" => "unitedstates", "UnitedStatesOfAmerica" => "unitedstatesofamerica");
274lookup!(TrinidadTable, Trinidad, "Trinidad And Tobago", 2, "Trinidad" => "trinidad", "Tobago" => "tobago");
275lookup!(TanzaniaTable, Tanzania, "United Republic Of Tanzania", 1, "Tanzania" => "tanzania");
276lookup!(TurkeyTable, Turkey, "Türkiye", 1, "Turkey" => "turkey");
277lookup!(TimorTable, TimorLeste, "Timor-Leste", 1, "EastTimor" => "easttimor");
278lookup!(CzechiaTable, Czechia, "Czechia", 1, "CzechRepublic" => "czechrepublic");
279
280/// Wrapper struct for alias tables to avoid using Box
281#[derive(Copy, Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd)]
282pub enum CountryTable {
283    /// Represents no aliases
284    Empty(EmptyLookupTable),
285    /// Aliases for Samoa
286    Samoa(SamoaTable),
287    /// Aliases for SaintHelena
288    SaintHelena(SaintHelenaTable),
289    /// Aliases for Venezuela
290    Venezuela(VenezuelaTable),
291    /// Aliases for Bosnia
292    Bosnia(BosniaTable),
293    /// Aliases for Brunei
294    Brunei(BruneiTable),
295    /// Aliases for Burkina
296    Burkina(BurkinaTable),
297    /// Aliases for StMaarten
298    StMaarten(StMaartenTable),
299    /// Aliases for Micronesia
300    Micronesia(MicronesiaTable),
301    /// Aliases for StMartin
302    StMartin(StMartinTable),
303    /// Aliases for HeardIsland
304    HeardIsland(HeardIslandTable),
305    /// Aliases for Iran
306    Iran(IranTable),
307    /// Aliases for Macedonia
308    Macedonia(MacedoniaTable),
309    /// Aliases for StBarthelemy
310    StBarthelemy(StBarthelemyTable),
311    /// Aliases for StKitts
312    StKitts(StKittsTable),
313    /// Aliases for StLucia
314    StLucia(StLuciaTable),
315    /// Aliases for StPierre
316    StPierre(StPierreTable),
317    /// Aliases for StVincent
318    StVincent(StVincentTable),
319    /// Aliases for SaoTome
320    SaoTome(SaoTomeTable),
321    /// Aliases for SouthGeorgia
322    SouthGeorgia(SouthGeorgiaTable),
323    /// Aliases for Palestine
324    Palestine(PalestineTable),
325    /// Aliases for Taiwan
326    Taiwan(TaiwanTable),
327    /// Aliases for Bahamas
328    Bahamas(BahamasTable),
329    /// Aliases for CaymanIslands
330    CaymanIslands(CaymanIslandsTable),
331    /// Aliases for CentralAfricanRepublic
332    CentralAfricanRepublic(CentralAfricanRepublicTable),
333    /// Aliases for CocosIslands
334    CocosIslands(CocosIslandsTable),
335    /// Aliases for Comoros
336    Comoros(ComorosTable),
337    /// Aliases for Congo
338    Congo(CongoTable),
339    /// Aliases for CookIslands
340    CookIslands(CookIslandsTable),
341    /// Aliases for NorthKorea
342    NorthKorea(NorthKoreaTable),
343    /// Aliases for DemocraticRepublicOfTheCongo
344    DemocraticRepublicOfTheCongo(DemocraticRepublicOfTheCongoTable),
345    /// Aliases for DominicanRepublic
346    DominicanRepublic(DominicanRepublicTable),
347    /// Aliases for Malvinas
348    Malvinas(MalvinasTable),
349    /// Aliases for FaroeIslands
350    FaroeIslands(FaroeIslandsTable),
351    /// Aliases for FrenchSouthernTerritories
352    FrenchSouthernTerritories(FrenchSouthernTerritoriesTable),
353    /// Aliases for Gabmia
354    Gambia(GambiaTable),
355    /// Aliases for HolySee
356    HolySee(HolySeeTable),
357    /// Aliases for LaoPeoplesDemocraticRepublic
358    LaoPeoplesDemocraticRepublic(LaoPeoplesDemocraticRepublicTable),
359    /// Aliases for MarshallIslands
360    MarshallIslands(MarshallIslandsTable),
361    /// Aliases for Netherlands
362    Netherlands(NetherlandsTable),
363    /// Aliases for Niger
364    Niger(NigerTable),
365    /// Aliases for NorthernMarianaIslands
366    NorthernMarianaIslands(NorthernMarianaIslandsTable),
367    /// Aliases for Philippines
368    Philippines(PhilippinesTable),
369    /// Aliases for SouthKorea
370    SouthKorea(SouthKoreaTable),
371    /// Aliases for Moldova
372    Moldova(MoldovaTable),
373    /// Aliases for Russia
374    Russia(RussiaTable),
375    /// Aliases for Sudan
376    Sudan(SudanTable),
377    /// Aliases for TurksAndCaicosIslands
378    TurksAndCaicosIslands(TurksAndCaicosIslandsTable),
379    /// Aliases for UnitedArabEmirates
380    UnitedArabEmirates(UnitedArabEmiratesTable),
381    /// Aliases for England
382    England(EnglandTable),
383    /// Aliases for UnitedStatesMinorOutlyingIslands
384    UnitedStatesMinorOutlyingIslands(UnitedStatesMinorOutlyingIslandsTable),
385    /// Aliases for America
386    America(AmericaTable),
387    /// Aliases for Trinidad
388    Trinidad(TrinidadTable),
389    /// Aliases for Tanzania
390    Tanzania(TanzaniaTable),
391    /// Aliases for Turkey
392    Turkey(TurkeyTable),
393    /// Aliases for TimorLeste
394    TimorLeste(TimorTable),
395    /// Aliases for Czechia
396    Czechia(CzechiaTable),
397}
398
399impl LookupTable for CountryTable {
400    fn contains(&self, alias: &str) -> bool {
401        match self {
402            CountryTable::Empty(e) => e.contains(alias),
403            CountryTable::Samoa(t) => t.contains(alias),
404            CountryTable::SaintHelena(t) => t.contains(alias),
405            CountryTable::Venezuela(t) => t.contains(alias),
406            CountryTable::Bosnia(t) => t.contains(alias),
407            CountryTable::Brunei(t) => t.contains(alias),
408            CountryTable::Burkina(t) => t.contains(alias),
409            CountryTable::StMaarten(t) => t.contains(alias),
410            CountryTable::Micronesia(t) => t.contains(alias),
411            CountryTable::StMartin(t) => t.contains(alias),
412            CountryTable::HeardIsland(t) => t.contains(alias),
413            CountryTable::Iran(t) => t.contains(alias),
414            CountryTable::Macedonia(t) => t.contains(alias),
415            CountryTable::StBarthelemy(t) => t.contains(alias),
416            CountryTable::StKitts(t) => t.contains(alias),
417            CountryTable::StLucia(t) => t.contains(alias),
418            CountryTable::StPierre(t) => t.contains(alias),
419            CountryTable::StVincent(t) => t.contains(alias),
420            CountryTable::SaoTome(t) => t.contains(alias),
421            CountryTable::SouthGeorgia(t) => t.contains(alias),
422            CountryTable::Palestine(t) => t.contains(alias),
423            CountryTable::Taiwan(t) => t.contains(alias),
424            CountryTable::Bahamas(t) => t.contains(alias),
425            CountryTable::CaymanIslands(t) => t.contains(alias),
426            CountryTable::CentralAfricanRepublic(t) => t.contains(alias),
427            CountryTable::CocosIslands(t) => t.contains(alias),
428            CountryTable::Comoros(t) => t.contains(alias),
429            CountryTable::Congo(t) => t.contains(alias),
430            CountryTable::CookIslands(t) => t.contains(alias),
431            CountryTable::NorthKorea(t) => t.contains(alias),
432            CountryTable::DemocraticRepublicOfTheCongo(t) => t.contains(alias),
433            CountryTable::DominicanRepublic(t) => t.contains(alias),
434            CountryTable::Malvinas(t) => t.contains(alias),
435            CountryTable::FaroeIslands(t) => t.contains(alias),
436            CountryTable::FrenchSouthernTerritories(t) => t.contains(alias),
437            CountryTable::Gambia(t) => t.contains(alias),
438            CountryTable::HolySee(t) => t.contains(alias),
439            CountryTable::LaoPeoplesDemocraticRepublic(t) => t.contains(alias),
440            CountryTable::MarshallIslands(t) => t.contains(alias),
441            CountryTable::Netherlands(t) => t.contains(alias),
442            CountryTable::Niger(t) => t.contains(alias),
443            CountryTable::NorthernMarianaIslands(t) => t.contains(alias),
444            CountryTable::Philippines(t) => t.contains(alias),
445            CountryTable::SouthKorea(t) => t.contains(alias),
446            CountryTable::Moldova(t) => t.contains(alias),
447            CountryTable::Russia(t) => t.contains(alias),
448            CountryTable::Sudan(t) => t.contains(alias),
449            CountryTable::TurksAndCaicosIslands(t) => t.contains(alias),
450            CountryTable::UnitedArabEmirates(t) => t.contains(alias),
451            CountryTable::England(t) => t.contains(alias),
452            CountryTable::UnitedStatesMinorOutlyingIslands(t) => t.contains(alias),
453            CountryTable::America(t) => t.contains(alias),
454            CountryTable::Trinidad(t) => t.contains(alias),
455            CountryTable::Tanzania(t) => t.contains(alias),
456            CountryTable::Turkey(t) => t.contains(alias),
457            CountryTable::TimorLeste(t) => t.contains(alias),
458            CountryTable::Czechia(t) => t.contains(alias),
459        }
460    }
461
462    fn len(&self) -> usize {
463        match self {
464            CountryTable::Empty(e) => e.len(),
465            CountryTable::Samoa(t) => t.len(),
466            CountryTable::SaintHelena(t) => t.len(),
467            CountryTable::Venezuela(t) => t.len(),
468            CountryTable::Bosnia(t) => t.len(),
469            CountryTable::Brunei(t) => t.len(),
470            CountryTable::Burkina(t) => t.len(),
471            CountryTable::StMaarten(t) => t.len(),
472            CountryTable::Micronesia(t) => t.len(),
473            CountryTable::StMartin(t) => t.len(),
474            CountryTable::HeardIsland(t) => t.len(),
475            CountryTable::Iran(t) => t.len(),
476            CountryTable::Macedonia(t) => t.len(),
477            CountryTable::StBarthelemy(t) => t.len(),
478            CountryTable::StKitts(t) => t.len(),
479            CountryTable::StLucia(t) => t.len(),
480            CountryTable::StPierre(t) => t.len(),
481            CountryTable::StVincent(t) => t.len(),
482            CountryTable::SaoTome(t) => t.len(),
483            CountryTable::SouthGeorgia(t) => t.len(),
484            CountryTable::Palestine(t) => t.len(),
485            CountryTable::Taiwan(t) => t.len(),
486            CountryTable::Bahamas(t) => t.len(),
487            CountryTable::CaymanIslands(t) => t.len(),
488            CountryTable::CentralAfricanRepublic(t) => t.len(),
489            CountryTable::CocosIslands(t) => t.len(),
490            CountryTable::Comoros(t) => t.len(),
491            CountryTable::Congo(t) => t.len(),
492            CountryTable::CookIslands(t) => t.len(),
493            CountryTable::NorthKorea(t) => t.len(),
494            CountryTable::DemocraticRepublicOfTheCongo(t) => t.len(),
495            CountryTable::DominicanRepublic(t) => t.len(),
496            CountryTable::Malvinas(t) => t.len(),
497            CountryTable::FaroeIslands(t) => t.len(),
498            CountryTable::FrenchSouthernTerritories(t) => t.len(),
499            CountryTable::Gambia(t) => t.len(),
500            CountryTable::HolySee(t) => t.len(),
501            CountryTable::LaoPeoplesDemocraticRepublic(t) => t.len(),
502            CountryTable::MarshallIslands(t) => t.len(),
503            CountryTable::Netherlands(t) => t.len(),
504            CountryTable::Niger(t) => t.len(),
505            CountryTable::NorthernMarianaIslands(t) => t.len(),
506            CountryTable::Philippines(t) => t.len(),
507            CountryTable::SouthKorea(t) => t.len(),
508            CountryTable::Moldova(t) => t.len(),
509            CountryTable::Russia(t) => t.len(),
510            CountryTable::Sudan(t) => t.len(),
511            CountryTable::TurksAndCaicosIslands(t) => t.len(),
512            CountryTable::UnitedArabEmirates(t) => t.len(),
513            CountryTable::England(t) => t.len(),
514            CountryTable::UnitedStatesMinorOutlyingIslands(t) => t.len(),
515            CountryTable::America(t) => t.len(),
516            CountryTable::Trinidad(t) => t.len(),
517            CountryTable::Tanzania(t) => t.len(),
518            CountryTable::Turkey(t) => t.len(),
519            CountryTable::TimorLeste(t) => t.len(),
520            CountryTable::Czechia(t) => t.len(),
521        }
522    }
523
524    fn iter(&self) -> Iter<'_, &'static str> {
525        match self {
526            CountryTable::Empty(e) => e.iter(),
527            CountryTable::Samoa(t) => t.iter(),
528            CountryTable::SaintHelena(t) => t.iter(),
529            CountryTable::Venezuela(t) => t.iter(),
530            CountryTable::Bosnia(t) => t.iter(),
531            CountryTable::Brunei(t) => t.iter(),
532            CountryTable::Burkina(t) => t.iter(),
533            CountryTable::StMaarten(t) => t.iter(),
534            CountryTable::Micronesia(t) => t.iter(),
535            CountryTable::StMartin(t) => t.iter(),
536            CountryTable::HeardIsland(t) => t.iter(),
537            CountryTable::Iran(t) => t.iter(),
538            CountryTable::Macedonia(t) => t.iter(),
539            CountryTable::StBarthelemy(t) => t.iter(),
540            CountryTable::StKitts(t) => t.iter(),
541            CountryTable::StLucia(t) => t.iter(),
542            CountryTable::StPierre(t) => t.iter(),
543            CountryTable::StVincent(t) => t.iter(),
544            CountryTable::SaoTome(t) => t.iter(),
545            CountryTable::SouthGeorgia(t) => t.iter(),
546            CountryTable::Palestine(t) => t.iter(),
547            CountryTable::Taiwan(t) => t.iter(),
548            CountryTable::Bahamas(t) => t.iter(),
549            CountryTable::CaymanIslands(t) => t.iter(),
550            CountryTable::CentralAfricanRepublic(t) => t.iter(),
551            CountryTable::CocosIslands(t) => t.iter(),
552            CountryTable::Comoros(t) => t.iter(),
553            CountryTable::Congo(t) => t.iter(),
554            CountryTable::CookIslands(t) => t.iter(),
555            CountryTable::NorthKorea(t) => t.iter(),
556            CountryTable::DemocraticRepublicOfTheCongo(t) => t.iter(),
557            CountryTable::DominicanRepublic(t) => t.iter(),
558            CountryTable::Malvinas(t) => t.iter(),
559            CountryTable::FaroeIslands(t) => t.iter(),
560            CountryTable::FrenchSouthernTerritories(t) => t.iter(),
561            CountryTable::Gambia(t) => t.iter(),
562            CountryTable::HolySee(t) => t.iter(),
563            CountryTable::LaoPeoplesDemocraticRepublic(t) => t.iter(),
564            CountryTable::MarshallIslands(t) => t.iter(),
565            CountryTable::Netherlands(t) => t.iter(),
566            CountryTable::Niger(t) => t.iter(),
567            CountryTable::NorthernMarianaIslands(t) => t.iter(),
568            CountryTable::Philippines(t) => t.iter(),
569            CountryTable::SouthKorea(t) => t.iter(),
570            CountryTable::Moldova(t) => t.iter(),
571            CountryTable::Russia(t) => t.iter(),
572            CountryTable::Sudan(t) => t.iter(),
573            CountryTable::TurksAndCaicosIslands(t) => t.iter(),
574            CountryTable::UnitedArabEmirates(t) => t.iter(),
575            CountryTable::England(t) => t.iter(),
576            CountryTable::UnitedStatesMinorOutlyingIslands(t) => t.iter(),
577            CountryTable::America(t) => t.iter(),
578            CountryTable::Trinidad(t) => t.iter(),
579            CountryTable::Tanzania(t) => t.iter(),
580            CountryTable::Turkey(t) => t.iter(),
581            CountryTable::TimorLeste(t) => t.iter(),
582            CountryTable::Czechia(t) => t.iter(),
583        }
584    }
585}
586
587impl fmt::Display for CountryTable {
588    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
589        match self {
590            CountryTable::Empty(e) => write!(f, "{}", e),
591            CountryTable::Samoa(t) => write!(f, "{}", t),
592            CountryTable::SaintHelena(t) => write!(f, "{}", t),
593            CountryTable::Venezuela(t) => write!(f, "{}", t),
594            CountryTable::Bosnia(t) => write!(f, "{}", t),
595            CountryTable::Brunei(t) => write!(f, "{}", t),
596            CountryTable::Burkina(t) => write!(f, "{}", t),
597            CountryTable::StMaarten(t) => write!(f, "{}", t),
598            CountryTable::Micronesia(t) => write!(f, "{}", t),
599            CountryTable::StMartin(t) => write!(f, "{}", t),
600            CountryTable::HeardIsland(t) => write!(f, "{}", t),
601            CountryTable::Iran(t) => write!(f, "{}", t),
602            CountryTable::Macedonia(t) => write!(f, "{}", t),
603            CountryTable::StBarthelemy(t) => write!(f, "{}", t),
604            CountryTable::StKitts(t) => write!(f, "{}", t),
605            CountryTable::StLucia(t) => write!(f, "{}", t),
606            CountryTable::StPierre(t) => write!(f, "{}", t),
607            CountryTable::StVincent(t) => write!(f, "{}", t),
608            CountryTable::SaoTome(t) => write!(f, "{}", t),
609            CountryTable::SouthGeorgia(t) => write!(f, "{}", t),
610            CountryTable::Palestine(t) => write!(f, "{}", t),
611            CountryTable::Taiwan(t) => write!(f, "{}", t),
612            CountryTable::Bahamas(t) => write!(f, "{}", t),
613            CountryTable::CaymanIslands(t) => write!(f, "{}", t),
614            CountryTable::CentralAfricanRepublic(t) => write!(f, "{}", t),
615            CountryTable::CocosIslands(t) => write!(f, "{}", t),
616            CountryTable::Comoros(t) => write!(f, "{}", t),
617            CountryTable::Congo(t) => write!(f, "{}", t),
618            CountryTable::CookIslands(t) => write!(f, "{}", t),
619            CountryTable::NorthKorea(t) => write!(f, "{}", t),
620            CountryTable::DemocraticRepublicOfTheCongo(t) => write!(f, "{}", t),
621            CountryTable::DominicanRepublic(t) => write!(f, "{}", t),
622            CountryTable::Malvinas(t) => write!(f, "{}", t),
623            CountryTable::FaroeIslands(t) => write!(f, "{}", t),
624            CountryTable::FrenchSouthernTerritories(t) => write!(f, "{}", t),
625            CountryTable::Gambia(t) => write!(f, "{}", t),
626            CountryTable::HolySee(t) => write!(f, "{}", t),
627            CountryTable::LaoPeoplesDemocraticRepublic(t) => write!(f, "{}", t),
628            CountryTable::MarshallIslands(t) => write!(f, "{}", t),
629            CountryTable::Netherlands(t) => write!(f, "{}", t),
630            CountryTable::Niger(t) => write!(f, "{}", t),
631            CountryTable::NorthernMarianaIslands(t) => write!(f, "{}", t),
632            CountryTable::Philippines(t) => write!(f, "{}", t),
633            CountryTable::SouthKorea(t) => write!(f, "{}", t),
634            CountryTable::Moldova(t) => write!(f, "{}", t),
635            CountryTable::Russia(t) => write!(f, "{}", t),
636            CountryTable::Sudan(t) => write!(f, "{}", t),
637            CountryTable::TurksAndCaicosIslands(t) => write!(f, "{}", t),
638            CountryTable::UnitedArabEmirates(t) => write!(f, "{}", t),
639            CountryTable::England(t) => write!(f, "{}", t),
640            CountryTable::UnitedStatesMinorOutlyingIslands(t) => write!(f, "{}", t),
641            CountryTable::America(t) => write!(f, "{}", t),
642            CountryTable::Trinidad(t) => write!(f, "{}", t),
643            CountryTable::Tanzania(t) => write!(f, "{}", t),
644            CountryTable::Turkey(t) => write!(f, "{}", t),
645            CountryTable::TimorLeste(t) => write!(f, "{}", t),
646            CountryTable::Czechia(t) => write!(f, "{}", t),
647        }
648    }
649}