Skip to main content

celes/
tables.rs

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