1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*!
This package contains an implementation of the [ISO
3166](https://www.iso.org/iso-3166-country-codes.html), parts 1 and 2,
standard.
The purpose of ISO 3166 is to define internationally recognized codes of
letters and/or numbers that we can use when we refer to countries and their
subdivisions. However, it does not define the names of countries – this
information comes from United Nations sources (Terminology Bulletin Country
Names and the Country and Region Codes for Statistical Use maintained by the
United Nations Statistics Divisions).
The country codes can be represented either as a two-letter code (alpha-2)
which is recommended as the general-purpose code, a three-letter code
(alpha-3) which is more closely related to the country name and a three-digit
numeric code (numeric-3) which can be useful if you need to avoid using Latin
script.
# Example
This example shows the use of the part-1 Country Code.
```rust
use codes_iso_3166::part_1::CountryCode;
use std::str::FromStr;
let country = CountryCode::from_str("AG").unwrap();
assert_eq!(country.alpha_2_code(), "AG");
assert_eq!(country.short_name(), "Antigua and Barbuda");
```
# Features
By default only the `serde` feature is enabled, and [part_1] two-letter
language codes.
* `serde` - Enables serialization of the different Language Code types.
* `alpha_3_code` - Adds the `CountryCode::alpha_3_code` method.
* `numeric_code` - Adds the `CountryCode::numeric_code` method.
* `independent` - Adds the `CountryCode::independent` method.
* `status` - Adds the `CountryCode::status` method.
* `full_name` - Adds the `CountryCode::full_name` method.
* `local_names` - Adds the `CountryCode::local_short_name` and
`CountryCode::local_full_name` methods.
* `languages` - Adds the `CountryCode::administrative_language` and `CountryCode::languages` methods (requires package `codes-iso-639`).
* `formerly` - Adds the `CountryCode::former_short_name` and
`CountryCode::former_alpha_3_code` methods.
* `part_2` - Adds the corresponding module and `SubdivisionCode`.
* `categories` - Adds the `SubdivisionCode::category_code` method and `SubdivisionCategoryCode` type.
* `territories` - Adds the `TerritoryCode` type.
* `languages` - Adds the `SubdivisionCode::name_language` method.
Note that the method `CountryCode::local_full_name` requires both
`local_names` and `full_name` features.
*/
// ------------------------------------------------------------------------------------------------
// Public Types
// ------------------------------------------------------------------------------------------------
pub use CodeParseError as CountryCodeError;
// ------------------------------------------------------------------------------------------------
// Modules
// ------------------------------------------------------------------------------------------------