summaryrefslogtreecommitdiffstats
path: root/vendor/icu_provider/src/request.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/icu_provider/src/request.rs')
-rw-r--r--vendor/icu_provider/src/request.rs40
1 files changed, 19 insertions, 21 deletions
diff --git a/vendor/icu_provider/src/request.rs b/vendor/icu_provider/src/request.rs
index 7f6bb5911..5f51f3a2c 100644
--- a/vendor/icu_provider/src/request.rs
+++ b/vendor/icu_provider/src/request.rs
@@ -53,11 +53,11 @@ pub struct DataRequestMetadata;
/// use icu_locid::locale;
/// use icu_provider::DataLocale;
///
-/// let locale1 = locale!("en-u-ca-buddhist");
-/// let data_locale = DataLocale::from(locale1);
-/// let locale2 = data_locale.into_locale();
+/// let locale = locale!("en-u-ca-buddhist");
+/// let data_locale = DataLocale::from(locale);
+/// let locale = data_locale.into_locale();
///
-/// assert_eq!(locale2.to_string(), "en-u-ca-buddhist");
+/// assert_eq!(locale, locale!("en-u-ca-buddhist"));
/// ```
///
/// You can alternatively create a [`DataLocale`] from a borrowed [`Locale`], which is more
@@ -81,18 +81,18 @@ pub struct DataRequestMetadata;
/// use icu_locid::langid;
/// use icu_provider::DataLocale;
///
-/// let langid1 = langid!("es-CA-valencia");
-/// let data_locale = DataLocale::from(langid1);
-/// let langid2 = data_locale.get_langid();
+/// let langid = langid!("es-CA-valencia");
+/// let data_locale = DataLocale::from(langid);
+/// let langid = data_locale.get_langid();
///
-/// assert_eq!(langid2.to_string(), "es-CA-valencia");
+/// assert_eq!(langid, langid!("es-CA-valencia"));
/// ```
///
/// [`DataLocale`] only supports `-u` keywords, to reflect the current state of CLDR data
/// lookup and fallback. This may change in the future.
///
/// ```
-/// use icu_locid::Locale;
+/// use icu_locid::{locale, Locale};
/// use icu_provider::DataLocale;
///
/// let locale = "hi-t-en-h0-hybrid-u-attr-ca-buddhist"
@@ -100,7 +100,7 @@ pub struct DataRequestMetadata;
/// .unwrap();
/// let data_locale = DataLocale::from(locale);
///
-/// assert_eq!(data_locale.to_string(), "hi-u-ca-buddhist");
+/// assert_eq!(data_locale.into_locale(), locale!("hi-u-ca-buddhist"));
/// ```
#[derive(PartialEq, Clone, Default, Eq, Hash)]
pub struct DataLocale {
@@ -225,7 +225,6 @@ impl DataLocale {
/// let b = ab[1];
/// assert!(a.cmp(b) == Ordering::Less);
/// let a_loc: DataLocale = a.parse::<Locale>().unwrap().into();
- /// assert_eq!(a, a_loc.to_string());
/// assert!(
/// a_loc.strict_cmp(a.as_bytes()) == Ordering::Equal,
/// "{} == {}",
@@ -239,7 +238,6 @@ impl DataLocale {
/// b
/// );
/// let b_loc: DataLocale = b.parse::<Locale>().unwrap().into();
- /// assert_eq!(b, b_loc.to_string());
/// assert!(
/// b_loc.strict_cmp(b.as_bytes()) == Ordering::Equal,
/// "{} == {}",
@@ -338,21 +336,20 @@ impl DataLocale {
///
/// ```
/// use icu_locid::{
- /// langid, subtags_language as language, subtags_region as region, Locale,
+ /// langid, locale, subtags_language as language, subtags_region as region,
+ /// Locale,
/// };
/// use icu_provider::prelude::*;
///
- /// let locale: Locale = "it-IT-u-ca-coptic".parse().expect("Valid BCP-47");
- /// let locale: DataLocale = locale.into();
+ /// let locale: DataLocale = locale!("it-IT-u-ca-coptic").into();
///
- /// assert_eq!(locale.to_string(), "it-IT-u-ca-coptic");
/// assert_eq!(locale.get_langid(), langid!("it-IT"));
/// assert_eq!(locale.language(), language!("it"));
/// assert_eq!(locale.script(), None);
/// assert_eq!(locale.region(), Some(region!("IT")));
///
/// let locale = locale.into_locale();
- /// assert_eq!(locale.to_string(), "it-IT-u-ca-coptic");
+ /// assert_eq!(locale, locale!("it-IT-u-ca-coptic"));
/// ```
pub fn into_locale(self) -> Locale {
let mut loc = Locale {
@@ -488,6 +485,8 @@ impl DataLocale {
#[test]
fn test_data_locale_to_string() {
+ use icu_locid::locale;
+
struct TestCase {
pub locale: DataLocale,
pub expected: &'static str,
@@ -499,15 +498,14 @@ fn test_data_locale_to_string() {
expected: "und",
},
TestCase {
- locale: "und-u-cu-gbp".parse::<Locale>().unwrap().into(),
+ locale: locale!("und-u-cu-gbp").into(),
expected: "und-u-cu-gbp",
},
TestCase {
- locale: "en-ZA-u-cu-gbp".parse::<Locale>().unwrap().into(),
+ locale: locale!("en-ZA-u-cu-gbp").into(),
expected: "en-ZA-u-cu-gbp",
},
] {
- assert_eq!(cas.expected, cas.locale.to_string());
- writeable::assert_writeable_eq!(&cas.locale, cas.expected);
+ writeable::assert_writeable_eq!(cas.locale, cas.expected);
}
}