diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
commit | 4f9fe856a25ab29345b90e7725509e9ee38a37be (patch) | |
tree | e4ffd8a9374cae7b21f7cbfb352927e0e074aff6 /vendor/icu_locid/README.md | |
parent | Adding upstream version 1.68.2+dfsg1. (diff) | |
download | rustc-5cd5bd4daf55da04d2c8e7c06c3067a027cfbfc2.tar.xz rustc-5cd5bd4daf55da04d2c8e7c06c3067a027cfbfc2.zip |
Adding upstream version 1.69.0+dfsg1.upstream/1.69.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | vendor/icu_locid/README.md | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/vendor/icu_locid/README.md b/vendor/icu_locid/README.md index cc2a0b023..5f49c35f5 100644 --- a/vendor/icu_locid/README.md +++ b/vendor/icu_locid/README.md @@ -20,36 +20,21 @@ If in doubt, use [`Locale`]. ## Examples ```rust -use icu::locid::subtags::{Language, Region}; use icu::locid::Locale; +use icu::locid::{ + locale, subtags_language as language, subtags_region as region, +}; -let mut loc: Locale = "en-US".parse().expect("Parsing failed."); - -let lang: Language = "en".parse().expect("Parsing failed."); -let region: Region = "US".parse().expect("Parsing failed."); +let mut loc: Locale = locale!("en-US"); -assert_eq!(loc.id.language, lang); +assert_eq!(loc.id.language, language!("en")); assert_eq!(loc.id.script, None); -assert_eq!(loc.id.region, Some(region)); +assert_eq!(loc.id.region, Some(region!("US"))); assert_eq!(loc.id.variants.len(), 0); -let region: Region = "GB".parse().expect("Parsing failed."); -loc.id.region = Some(region); - -assert_eq!(loc.to_string(), "en-GB"); -``` - -### Macros - -```rust -use icu::locid::{ - langid, subtags_language as language, subtags_region as region, -}; - -let lid = langid!("EN_US"); +loc.id.region = Some(region!("GB")); -assert_eq!(lid.language, language!("en")); -assert_eq!(lid.region, Some(region!("US"))); +assert_eq!(loc, locale!("en-GB")); ``` For more details, see [`Locale`] and [`LanguageIdentifier`]. |