diff --git a/components/calendar/src/buddhist.rs b/components/calendar/src/buddhist.rs index 7d7876c9f6e..bfd1ff22871 100644 --- a/components/calendar/src/buddhist.rs +++ b/components/calendar/src/buddhist.rs @@ -190,9 +190,8 @@ impl DateTime { /// ```rust /// use icu::calendar::DateTime; /// - /// let datetime_buddhist = - /// DateTime::try_new_buddhist(1970, 1, 2, 13, 1, 0) - /// .expect("Failed to initialize Buddhist DateTime instance."); + /// let datetime_buddhist = DateTime::try_new_buddhist(1970, 1, 2, 13, 1, 0) + /// .expect("Failed to initialize Buddhist DateTime instance."); /// /// assert_eq!(datetime_buddhist.date.year().era_year_or_extended(), 1970); /// assert_eq!(datetime_buddhist.date.month().ordinal, 1); diff --git a/components/calendar/src/chinese.rs b/components/calendar/src/chinese.rs index bb9622aec21..3be75e6eb51 100644 --- a/components/calendar/src/chinese.rs +++ b/components/calendar/src/chinese.rs @@ -11,15 +11,13 @@ //! let chinese = Ref(&chinese); // to avoid cloning //! //! // `Date` type -//! let chinese_date = -//! Date::try_new_chinese_with_calendar(4660, 6, 6, chinese) -//! .expect("Failed to initialize Chinese Date instance."); +//! let chinese_date = Date::try_new_chinese_with_calendar(4660, 6, 6, chinese) +//! .expect("Failed to initialize Chinese Date instance."); //! //! // `DateTime` type -//! let chinese_datetime = DateTime::try_new_chinese_with_calendar( -//! 4660, 6, 6, 13, 1, 0, chinese, -//! ) -//! .expect("Failed to initialize Chinese DateTime instance"); +//! let chinese_datetime = +//! DateTime::try_new_chinese_with_calendar(4660, 6, 6, 13, 1, 0, chinese) +//! .expect("Failed to initialize Chinese DateTime instance"); //! //! // `Date` checks //! assert_eq!(chinese_date.year().era_year_or_extended(), 4660); @@ -364,10 +362,9 @@ impl> DateTime { /// /// let chinese = Chinese::new_always_calculating(); /// - /// let chinese_datetime = DateTime::try_new_chinese_with_calendar( - /// 4660, 6, 11, 13, 1, 0, chinese, - /// ) - /// .expect("Failed to initialize Chinese DateTime instance."); + /// let chinese_datetime = + /// DateTime::try_new_chinese_with_calendar(4660, 6, 11, 13, 1, 0, chinese) + /// .expect("Failed to initialize Chinese DateTime instance."); /// /// assert_eq!(chinese_datetime.date.year().era_year_or_extended(), 4660); /// assert_eq!(chinese_datetime.date.year().cyclic().unwrap().get(), 40); diff --git a/components/calendar/src/coptic.rs b/components/calendar/src/coptic.rs index ffdd851221f..1d78cbb0c22 100644 --- a/components/calendar/src/coptic.rs +++ b/components/calendar/src/coptic.rs @@ -279,9 +279,8 @@ impl DateTime { /// ```rust /// use icu::calendar::DateTime; /// - /// let datetime_coptic = - /// DateTime::try_new_coptic(1686, 5, 6, 13, 1, 0) - /// .expect("Failed to initialize Coptic DateTime instance."); + /// let datetime_coptic = DateTime::try_new_coptic(1686, 5, 6, 13, 1, 0) + /// .expect("Failed to initialize Coptic DateTime instance."); /// /// assert_eq!(datetime_coptic.date.year().era_year_or_extended(), 1686); /// assert_eq!(datetime_coptic.date.month().ordinal, 5); diff --git a/components/calendar/src/dangi.rs b/components/calendar/src/dangi.rs index d2c0b708c69..a92848d4bf5 100644 --- a/components/calendar/src/dangi.rs +++ b/components/calendar/src/dangi.rs @@ -16,10 +16,9 @@ //! .expect("Failed to initialize Dangi Date instance."); //! //! // `DateTime` type -//! let dangi_datetime = DateTime::try_new_dangi_with_calendar( -//! 4356, 6, 6, 13, 1, 0, dangi, -//! ) -//! .expect("Failed to initialize Dangi DateTime instance."); +//! let dangi_datetime = +//! DateTime::try_new_dangi_with_calendar(4356, 6, 6, 13, 1, 0, dangi) +//! .expect("Failed to initialize Dangi DateTime instance."); //! //! // `Date` checks //! assert_eq!(dangi_date.year().era_year_or_extended(), 4356); @@ -343,10 +342,9 @@ impl> DateTime { /// /// let dangi = Dangi::new(); /// - /// let dangi_datetime = DateTime::try_new_dangi_with_calendar( - /// 4356, 6, 6, 13, 1, 0, dangi, - /// ) - /// .expect("Failed to initialize Dangi DateTime instance."); + /// let dangi_datetime = + /// DateTime::try_new_dangi_with_calendar(4356, 6, 6, 13, 1, 0, dangi) + /// .expect("Failed to initialize Dangi DateTime instance."); /// /// assert_eq!(dangi_datetime.date.year().era_year_or_extended(), 4356); /// assert_eq!(dangi_datetime.date.year().cyclic().unwrap().get(), 40); diff --git a/components/calendar/src/ethiopian.rs b/components/calendar/src/ethiopian.rs index 5415e6b3dc4..b401a3a5fb5 100644 --- a/components/calendar/src/ethiopian.rs +++ b/components/calendar/src/ethiopian.rs @@ -342,13 +342,9 @@ impl Date { /// use icu::calendar::cal::EthiopianEraStyle; /// use icu::calendar::Date; /// - /// let date_ethiopian = Date::try_new_ethiopian( - /// EthiopianEraStyle::AmeteMihret, - /// 2014, - /// 8, - /// 25, - /// ) - /// .expect("Failed to initialize Ethopic Date instance."); + /// let date_ethiopian = + /// Date::try_new_ethiopian(EthiopianEraStyle::AmeteMihret, 2014, 8, 25) + /// .expect("Failed to initialize Ethopic Date instance."); /// /// assert_eq!(date_ethiopian.year().era_year_or_extended(), 2014); /// assert_eq!(date_ethiopian.month().ordinal, 8); diff --git a/components/calendar/src/gregorian.rs b/components/calendar/src/gregorian.rs index 28d40dda42a..e5269906629 100644 --- a/components/calendar/src/gregorian.rs +++ b/components/calendar/src/gregorian.rs @@ -204,9 +204,8 @@ impl DateTime { /// ```rust /// use icu::calendar::DateTime; /// - /// let datetime_gregorian = - /// DateTime::try_new_gregorian(1970, 1, 2, 13, 1, 0) - /// .expect("Failed to initialize Gregorian DateTime instance."); + /// let datetime_gregorian = DateTime::try_new_gregorian(1970, 1, 2, 13, 1, 0) + /// .expect("Failed to initialize Gregorian DateTime instance."); /// /// assert_eq!(datetime_gregorian.date.year().era_year_or_extended(), 1970); /// assert_eq!(datetime_gregorian.date.month().ordinal, 1); diff --git a/components/calendar/src/hebrew.rs b/components/calendar/src/hebrew.rs index aafc5764511..9aca0b3a2e7 100644 --- a/components/calendar/src/hebrew.rs +++ b/components/calendar/src/hebrew.rs @@ -12,9 +12,8 @@ //! .expect("Failed to initialize hebrew Date instance."); //! //! // `DateTime` type -//! let hebrew_datetime = -//! DateTime::try_new_hebrew(3425, 10, 11, 13, 1, 0) -//! .expect("Failed to initialize hebrew DateTime instance."); +//! let hebrew_datetime = DateTime::try_new_hebrew(3425, 10, 11, 13, 1, 0) +//! .expect("Failed to initialize hebrew DateTime instance."); //! //! // `Date` checks //! assert_eq!(hebrew_date.year().era_year_or_extended(), 3425); @@ -382,9 +381,8 @@ impl DateTime { /// ```rust /// use icu::calendar::DateTime; /// - /// let datetime_hebrew = - /// DateTime::try_new_hebrew(4201, 10, 11, 13, 1, 0) - /// .expect("Failed to initialize Hebrew DateTime instance"); + /// let datetime_hebrew = DateTime::try_new_hebrew(4201, 10, 11, 13, 1, 0) + /// .expect("Failed to initialize Hebrew DateTime instance"); /// /// assert_eq!(datetime_hebrew.date.year().era_year_or_extended(), 4201); /// assert_eq!(datetime_hebrew.date.month().ordinal, 10); diff --git a/components/calendar/src/indian.rs b/components/calendar/src/indian.rs index 48107f89be7..2c489b5f648 100644 --- a/components/calendar/src/indian.rs +++ b/components/calendar/src/indian.rs @@ -286,9 +286,8 @@ impl DateTime { /// ```rust /// use icu::calendar::DateTime; /// - /// let datetime_indian = - /// DateTime::try_new_indian(1891, 10, 12, 13, 1, 0) - /// .expect("Failed to initialize Indian DateTime instance."); + /// let datetime_indian = DateTime::try_new_indian(1891, 10, 12, 13, 1, 0) + /// .expect("Failed to initialize Indian DateTime instance."); /// /// assert_eq!(datetime_indian.date.year().era_year_or_extended(), 1891); /// assert_eq!(datetime_indian.date.month().ordinal, 10); diff --git a/components/calendar/src/islamic.rs b/components/calendar/src/islamic.rs index 69708c4c2a0..d70f17a3fcd 100644 --- a/components/calendar/src/islamic.rs +++ b/components/calendar/src/islamic.rs @@ -12,15 +12,17 @@ //! let islamic = Ref(&islamic); // to avoid cloning //! //! // `Date` type -//! let islamic_date = -//! Date::try_new_observational_islamic_with_calendar(1348, 10, 11, islamic) -//! .expect("Failed to initialize islamic Date instance."); +//! let islamic_date = Date::try_new_observational_islamic_with_calendar( +//! 1348, 10, 11, islamic, +//! ) +//! .expect("Failed to initialize islamic Date instance."); //! //! // `DateTime` type -//! let islamic_datetime = DateTime::try_new_observational_islamic_with_calendar( -//! 1348, 10, 11, 13, 1, 0, islamic, -//! ) -//! .expect("Failed to initialize islamic DateTime instance."); +//! let islamic_datetime = +//! DateTime::try_new_observational_islamic_with_calendar( +//! 1348, 10, 11, 13, 1, 0, islamic, +//! ) +//! .expect("Failed to initialize islamic DateTime instance."); //! //! // `Date` checks //! assert_eq!(islamic_date.year().era_year_or_extended(), 1348); @@ -602,10 +604,11 @@ impl> DateTime { /// /// let islamic = IslamicObservational::new_always_calculating(); /// - /// let datetime_islamic = DateTime::try_new_observational_islamic_with_calendar( - /// 474, 10, 11, 13, 1, 0, islamic, - /// ) - /// .expect("Failed to initialize Islamic DateTime instance."); + /// let datetime_islamic = + /// DateTime::try_new_observational_islamic_with_calendar( + /// 474, 10, 11, 13, 1, 0, islamic, + /// ) + /// .expect("Failed to initialize Islamic DateTime instance."); /// /// assert_eq!(datetime_islamic.date.year().era_year_or_extended(), 474); /// assert_eq!(datetime_islamic.date.month().ordinal, 10); @@ -794,8 +797,9 @@ impl> Date { /// /// let islamic = IslamicUmmAlQura::new_always_calculating(); /// - /// let date_islamic = Date::try_new_ummalqura_with_calendar(1392, 4, 25, islamic) - /// .expect("Failed to initialize Islamic Date instance."); + /// let date_islamic = + /// Date::try_new_ummalqura_with_calendar(1392, 4, 25, islamic) + /// .expect("Failed to initialize Islamic Date instance."); /// /// assert_eq!(date_islamic.year().era_year_or_extended(), 1392); /// assert_eq!(date_islamic.month().ordinal, 4); @@ -829,9 +833,10 @@ impl> DateTime { /// /// let islamic = IslamicUmmAlQura::new_always_calculating(); /// - /// let datetime_islamic = - /// DateTime::try_new_ummalqura_with_calendar(474, 10, 11, 13, 1, 0, islamic) - /// .expect("Failed to initialize Islamic DateTime instance."); + /// let datetime_islamic = DateTime::try_new_ummalqura_with_calendar( + /// 474, 10, 11, 13, 1, 0, islamic, + /// ) + /// .expect("Failed to initialize Islamic DateTime instance."); /// /// assert_eq!(datetime_islamic.date.year().era_year_or_extended(), 474); /// assert_eq!(datetime_islamic.date.month().ordinal, 10); @@ -1060,11 +1065,10 @@ impl> DateTime { /// /// let islamic = IslamicCivil::new(); /// - /// let datetime_islamic = - /// DateTime::try_new_islamic_civil_with_calendar( - /// 474, 10, 11, 13, 1, 0, islamic, - /// ) - /// .expect("Failed to initialize Islamic DateTime instance."); + /// let datetime_islamic = DateTime::try_new_islamic_civil_with_calendar( + /// 474, 10, 11, 13, 1, 0, islamic, + /// ) + /// .expect("Failed to initialize Islamic DateTime instance."); /// /// assert_eq!(datetime_islamic.date.year().era_year_or_extended(), 474); /// assert_eq!(datetime_islamic.date.month().ordinal, 10); @@ -1292,11 +1296,10 @@ impl> DateTime { /// /// let islamic = IslamicTabular::new(); /// - /// let datetime_islamic = - /// DateTime::try_new_islamic_tabular_with_calendar( - /// 474, 10, 11, 13, 1, 0, islamic, - /// ) - /// .expect("Failed to initialize Islamic DateTime instance."); + /// let datetime_islamic = DateTime::try_new_islamic_tabular_with_calendar( + /// 474, 10, 11, 13, 1, 0, islamic, + /// ) + /// .expect("Failed to initialize Islamic DateTime instance."); /// /// assert_eq!(datetime_islamic.date.year().era_year_or_extended(), 474); /// assert_eq!(datetime_islamic.date.month().ordinal, 10); diff --git a/components/calendar/src/ixdtf.rs b/components/calendar/src/ixdtf.rs index 36d07473f7e..bb00d8768d8 100644 --- a/components/calendar/src/ixdtf.rs +++ b/components/calendar/src/ixdtf.rs @@ -206,7 +206,8 @@ impl DateTime { /// ``` /// use icu::calendar::DateTime; /// - /// let datetime = DateTime::try_iso_from_str("2024-07-17T16:01:17.045").unwrap(); + /// let datetime = + /// DateTime::try_iso_from_str("2024-07-17T16:01:17.045").unwrap(); /// /// assert_eq!(datetime.date.year().era_year_or_extended(), 2024); /// assert_eq!( @@ -258,7 +259,8 @@ impl DateTime { /// ``` /// use icu::calendar::DateTime; /// - /// let datetime = DateTime::try_from_str("2024-07-17T16:01:17.045[u-ca=hebrew]").unwrap(); + /// let datetime = + /// DateTime::try_from_str("2024-07-17T16:01:17.045[u-ca=hebrew]").unwrap(); /// /// assert_eq!(datetime.date.year().era_year_or_extended(), 5784); /// assert_eq!( diff --git a/components/calendar/src/japanese.rs b/components/calendar/src/japanese.rs index 7e7d67b62bc..c61330d51b6 100644 --- a/components/calendar/src/japanese.rs +++ b/components/calendar/src/japanese.rs @@ -26,7 +26,10 @@ //! assert_eq!(date_japanese.year().era_year_or_extended(), 45); //! assert_eq!(date_japanese.month().ordinal, 1); //! assert_eq!(date_japanese.day_of_month().0, 2); -//! assert_eq!(date_japanese.year().standard_era().unwrap(), Era(tinystr!(16, "showa"))); +//! assert_eq!( +//! date_japanese.year().standard_era().unwrap(), +//! Era(tinystr!(16, "showa")) +//! ); //! //! // `DateTime` type //! assert_eq!(datetime_japanese.date.year().era_year_or_extended(), 45); @@ -430,8 +433,9 @@ impl Date { /// /// let era = types::Era(tinystr!(16, "heisei")); /// - /// let date = Date::try_new_japanese_with_calendar(era, 14, 1, 2, japanese_calendar) - /// .expect("Constructing a date should succeed"); + /// let date = + /// Date::try_new_japanese_with_calendar(era, 14, 1, 2, japanese_calendar) + /// .expect("Constructing a date should succeed"); /// /// assert_eq!(date.year().standard_era().unwrap(), era); /// assert_eq!(date.year().era_year_or_extended(), 14); @@ -446,8 +450,13 @@ impl Date { /// /// // and for unknown eras /// let fake_era = types::Era(tinystr!(16, "neko")); // 🐱 - /// let fake_date = - /// Date::try_new_japanese_with_calendar(fake_era, 10, 1, 2, japanese_calendar); + /// let fake_date = Date::try_new_japanese_with_calendar( + /// fake_era, + /// 10, + /// 1, + /// 2, + /// japanese_calendar, + /// ); /// assert!(fake_date.is_err()); /// ``` pub fn try_new_japanese_with_calendar>( @@ -484,9 +493,14 @@ impl Date { /// /// let era = types::Era(tinystr!(16, "kansei-1789")); /// - /// let date = - /// Date::try_new_japanese_extended_with_calendar(era, 7, 1, 2, japanext_calendar) - /// .expect("Constructing a date should succeed"); + /// let date = Date::try_new_japanese_extended_with_calendar( + /// era, + /// 7, + /// 1, + /// 2, + /// japanext_calendar, + /// ) + /// .expect("Constructing a date should succeed"); /// /// assert_eq!(date.year().standard_era().unwrap(), era); /// assert_eq!(date.year().era_year_or_extended(), 7); diff --git a/components/calendar/src/julian.rs b/components/calendar/src/julian.rs index 0af197576dd..3f3f71cbf3c 100644 --- a/components/calendar/src/julian.rs +++ b/components/calendar/src/julian.rs @@ -304,9 +304,8 @@ impl DateTime { /// ```rust /// use icu::calendar::DateTime; /// - /// let datetime_julian = - /// DateTime::try_new_julian(1969, 12, 20, 13, 1, 0) - /// .expect("Failed to initialize Julian DateTime instance."); + /// let datetime_julian = DateTime::try_new_julian(1969, 12, 20, 13, 1, 0) + /// .expect("Failed to initialize Julian DateTime instance."); /// /// assert_eq!(datetime_julian.date.year().era_year_or_extended(), 1969); /// assert_eq!(datetime_julian.date.month().ordinal, 12); diff --git a/components/calendar/src/persian.rs b/components/calendar/src/persian.rs index bc3f7d91c27..edb650bc69c 100644 --- a/components/calendar/src/persian.rs +++ b/components/calendar/src/persian.rs @@ -12,9 +12,8 @@ //! .expect("Failed to initialize Persian Date instance."); //! //! // `DateTime` type -//! let persian_datetime = -//! DateTime::try_new_persian(1348, 10, 11, 13, 1, 0) -//! .expect("Failed to initialize Persian DateTime instance."); +//! let persian_datetime = DateTime::try_new_persian(1348, 10, 11, 13, 1, 0) +//! .expect("Failed to initialize Persian DateTime instance."); //! //! // `Date` checks //! assert_eq!(persian_date.year().era_year_or_extended(), 1348); @@ -262,9 +261,8 @@ impl DateTime { /// ```rust /// use icu::calendar::DateTime; /// - /// let datetime_persian = - /// DateTime::try_new_persian(474, 10, 11, 13, 1, 0) - /// .expect("Failed to initialize Persian DateTime instance."); + /// let datetime_persian = DateTime::try_new_persian(474, 10, 11, 13, 1, 0) + /// .expect("Failed to initialize Persian DateTime instance."); /// /// assert_eq!(datetime_persian.date.year().era_year_or_extended(), 474); /// assert_eq!(datetime_persian.date.month().ordinal, 10); diff --git a/components/calendar/src/roc.rs b/components/calendar/src/roc.rs index e3662b1cc7e..a53a7a75516 100644 --- a/components/calendar/src/roc.rs +++ b/components/calendar/src/roc.rs @@ -234,8 +234,15 @@ impl DateTime { /// let datetime_roc = DateTime::try_new_roc(1, 2, 3, 13, 1, 0) /// .expect("Failed to initialize ROC DateTime instance."); /// - /// assert_eq!(datetime_roc.date.year().standard_era().unwrap().0, tinystr!(16, "roc")); - /// assert_eq!(datetime_roc.date.year().era_year_or_extended(), 1, "ROC year check failed!"); + /// assert_eq!( + /// datetime_roc.date.year().standard_era().unwrap().0, + /// tinystr!(16, "roc") + /// ); + /// assert_eq!( + /// datetime_roc.date.year().era_year_or_extended(), + /// 1, + /// "ROC year check failed!" + /// ); /// assert_eq!( /// datetime_roc.date.month().ordinal, /// 2, diff --git a/components/collator/README.md b/components/collator/README.md index a36268d1d7f..89c640b7ea7 100644 --- a/components/collator/README.md +++ b/components/collator/README.md @@ -25,7 +25,8 @@ use icu::locale::locale; let mut options = CollatorOptions::default(); options.strength = Some(Strength::Primary); -let collator_es = Collator::try_new(locale!("es-u-co-trad").into(), options).unwrap(); +let collator_es = + Collator::try_new(locale!("es-u-co-trad").into(), options).unwrap(); // "pollo" > "polvo" in traditional Spanish assert_eq!(collator_es.compare("pollo", "polvo"), Ordering::Greater); diff --git a/components/collator/src/lib.rs b/components/collator/src/lib.rs index d8ce49dc3cb..5ebfb49ca8a 100644 --- a/components/collator/src/lib.rs +++ b/components/collator/src/lib.rs @@ -45,7 +45,8 @@ //! //! let mut options = CollatorOptions::default(); //! options.strength = Some(Strength::Primary); -//! let collator_es = Collator::try_new(locale!("es-u-co-trad").into(), options).unwrap(); +//! let collator_es = +//! Collator::try_new(locale!("es-u-co-trad").into(), options).unwrap(); //! //! // "pollo" > "polvo" in traditional Spanish //! assert_eq!(collator_es.compare("pollo", "polvo"), Ordering::Greater); diff --git a/components/collections/src/codepointinvlist/builder.rs b/components/collections/src/codepointinvlist/builder.rs index 894046c0ff0..f5b019dd58f 100644 --- a/components/collections/src/codepointinvlist/builder.rs +++ b/components/collections/src/codepointinvlist/builder.rs @@ -172,9 +172,10 @@ impl CodePointInversionListBuilder { /// CodePointInversionList, CodePointInversionListBuilder, /// }; /// let mut builder = CodePointInversionListBuilder::new(); - /// let set = - /// CodePointInversionList::try_from_u32_inversion_list_slice(&[0x41, 0x4C]) - /// .unwrap(); + /// let set = CodePointInversionList::try_from_u32_inversion_list_slice(&[ + /// 0x41, 0x4C, + /// ]) + /// .unwrap(); /// builder.add_set(&set); /// let check = builder.build(); /// assert_eq!(check.iter_chars().next(), Some('A')); @@ -340,8 +341,9 @@ impl CodePointInversionListBuilder { /// CodePointInversionList, CodePointInversionListBuilder, /// }; /// let mut builder = CodePointInversionListBuilder::new(); - /// let set = CodePointInversionList::try_from_u32_inversion_list_slice(&[65, 70]) - /// .unwrap(); + /// let set = + /// CodePointInversionList::try_from_u32_inversion_list_slice(&[65, 70]) + /// .unwrap(); /// builder.add_range('A'..='Z'); /// builder.retain_set(&set); // retains 'A'..='E' /// let check = builder.build(); diff --git a/components/collections/src/codepointinvlist/cpinvlist.rs b/components/collections/src/codepointinvlist/cpinvlist.rs index 175fe26d432..1b4eb516e71 100644 --- a/components/collections/src/codepointinvlist/cpinvlist.rs +++ b/components/collections/src/codepointinvlist/cpinvlist.rs @@ -185,23 +185,30 @@ impl<'data> CodePointInversionList<'data> { /// ``` /// use icu::collections::codepointinvlist::CodePointInversionList; /// use icu::collections::codepointinvlist::InvalidSetError; - /// use zerovec::ZeroVec; /// use potential_utf::PotentialCodePoint; + /// use zerovec::ZeroVec; /// /// let valid = [0x0, 0x10000]; - /// let inv_list: ZeroVec = valid.into_iter().map(PotentialCodePoint::from_u24).collect(); + /// let inv_list: ZeroVec = valid + /// .into_iter() + /// .map(PotentialCodePoint::from_u24) + /// .collect(); /// let result = CodePointInversionList::try_from_inversion_list(inv_list); /// assert!(matches!(result, CodePointInversionList)); /// /// let invalid = vec![0x0, 0x80, 0x3]; - /// let inv_list: ZeroVec = invalid.iter().copied().map(PotentialCodePoint::from_u24).collect(); + /// let inv_list: ZeroVec = invalid + /// .iter() + /// .copied() + /// .map(PotentialCodePoint::from_u24) + /// .collect(); /// let result = CodePointInversionList::try_from_inversion_list(inv_list); - /// assert!(matches!( - /// result, - /// Err(InvalidSetError(_)) - /// )); + /// assert!(matches!(result, Err(InvalidSetError(_)))); /// if let Err(InvalidSetError(actual)) = result { - /// assert_eq!(&invalid, &actual.into_iter().map(u32::from).collect::>()); + /// assert_eq!( + /// &invalid, + /// &actual.into_iter().map(u32::from).collect::>() + /// ); /// } /// ``` pub fn try_from_inversion_list( @@ -351,9 +358,10 @@ impl<'data> CodePointInversionList<'data> { /// ``` /// use icu::collections::codepointinvlist::CodePointInversionList; /// let example_list = [0x41, 0x44, 0x45, 0x46]; - /// let example = - /// CodePointInversionList::try_from_u32_inversion_list_slice(&example_list) - /// .unwrap(); + /// let example = CodePointInversionList::try_from_u32_inversion_list_slice( + /// &example_list, + /// ) + /// .unwrap(); /// let mut ex_iter_chars = example.iter_chars(); /// assert_eq!(Some('A'), ex_iter_chars.next()); /// assert_eq!(Some('B'), ex_iter_chars.next()); @@ -385,9 +393,10 @@ impl<'data> CodePointInversionList<'data> { /// ``` /// use icu::collections::codepointinvlist::CodePointInversionList; /// let example_list = [0x41, 0x44, 0x45, 0x46]; - /// let example = - /// CodePointInversionList::try_from_u32_inversion_list_slice(&example_list) - /// .unwrap(); + /// let example = CodePointInversionList::try_from_u32_inversion_list_slice( + /// &example_list, + /// ) + /// .unwrap(); /// let mut example_iter_ranges = example.iter_ranges(); /// assert_eq!(Some(0x41..=0x43), example_iter_ranges.next()); /// assert_eq!(Some(0x45..=0x45), example_iter_ranges.next()); @@ -414,9 +423,10 @@ impl<'data> CodePointInversionList<'data> { /// ``` /// use icu::collections::codepointinvlist::CodePointInversionList; /// let example_list = [0x41, 0x44, 0x45, 0x46]; - /// let example = - /// CodePointInversionList::try_from_u32_inversion_list_slice(&example_list) - /// .unwrap(); + /// let example = CodePointInversionList::try_from_u32_inversion_list_slice( + /// &example_list, + /// ) + /// .unwrap(); /// let mut example_iter_ranges = example.iter_ranges_complemented(); /// assert_eq!(Some(0..=0x40), example_iter_ranges.next()); /// assert_eq!(Some(0x44..=0x44), example_iter_ranges.next()); @@ -517,9 +527,10 @@ impl<'data> CodePointInversionList<'data> { /// ``` /// use icu::collections::codepointinvlist::CodePointInversionList; /// let example_list = [0x41, 0x43, 0x44, 0x45]; - /// let example = - /// CodePointInversionList::try_from_u32_inversion_list_slice(&example_list) - /// .unwrap(); + /// let example = CodePointInversionList::try_from_u32_inversion_list_slice( + /// &example_list, + /// ) + /// .unwrap(); /// assert!(example.contains('A')); /// assert!(!example.contains('C')); /// ``` @@ -542,9 +553,10 @@ impl<'data> CodePointInversionList<'data> { /// ``` /// use icu::collections::codepointinvlist::CodePointInversionList; /// let example_list = [0x41, 0x43, 0x44, 0x45]; - /// let example = - /// CodePointInversionList::try_from_u32_inversion_list_slice(&example_list) - /// .unwrap(); + /// let example = CodePointInversionList::try_from_u32_inversion_list_slice( + /// &example_list, + /// ) + /// .unwrap(); /// assert!(example.contains32(0x41)); /// assert!(!example.contains32(0x43)); /// ``` @@ -563,9 +575,10 @@ impl<'data> CodePointInversionList<'data> { /// ``` /// use icu::collections::codepointinvlist::CodePointInversionList; /// let example_list = [0x41, 0x43, 0x44, 0x45]; - /// let example = - /// CodePointInversionList::try_from_u32_inversion_list_slice(&example_list) - /// .unwrap(); + /// let example = CodePointInversionList::try_from_u32_inversion_list_slice( + /// &example_list, + /// ) + /// .unwrap(); /// assert!(example.contains_range('A'..'C')); /// assert!(example.contains_range('A'..='B')); /// assert!(!example.contains_range('A'..='C')); @@ -587,9 +600,10 @@ impl<'data> CodePointInversionList<'data> { /// let check = /// char::from_u32(0xD7FE).unwrap()..char::from_u32(0xE001).unwrap(); /// let example_list = [0xD7FE, 0xD7FF, 0xE000, 0xE001]; - /// let example = - /// CodePointInversionList::try_from_u32_inversion_list_slice(&example_list) - /// .unwrap(); + /// let example = CodePointInversionList::try_from_u32_inversion_list_slice( + /// &example_list, + /// ) + /// .unwrap(); /// assert!(!example.contains_range(check)); /// ``` pub fn contains_range(&self, range: impl RangeBounds) -> bool { @@ -620,18 +634,22 @@ impl<'data> CodePointInversionList<'data> { /// ``` /// use icu::collections::codepointinvlist::CodePointInversionList; /// let example_list = [0x41, 0x46, 0x55, 0x5B]; // A - E, U - Z - /// let example = - /// CodePointInversionList::try_from_u32_inversion_list_slice(&example_list) - /// .unwrap(); - /// let a_to_d = - /// CodePointInversionList::try_from_u32_inversion_list_slice(&[0x41, 0x45]) - /// .unwrap(); - /// let f_to_t = - /// CodePointInversionList::try_from_u32_inversion_list_slice(&[0x46, 0x55]) - /// .unwrap(); - /// let r_to_x = - /// CodePointInversionList::try_from_u32_inversion_list_slice(&[0x52, 0x58]) - /// .unwrap(); + /// let example = CodePointInversionList::try_from_u32_inversion_list_slice( + /// &example_list, + /// ) + /// .unwrap(); + /// let a_to_d = CodePointInversionList::try_from_u32_inversion_list_slice(&[ + /// 0x41, 0x45, + /// ]) + /// .unwrap(); + /// let f_to_t = CodePointInversionList::try_from_u32_inversion_list_slice(&[ + /// 0x46, 0x55, + /// ]) + /// .unwrap(); + /// let r_to_x = CodePointInversionList::try_from_u32_inversion_list_slice(&[ + /// 0x52, 0x58, + /// ]) + /// .unwrap(); /// assert!(example.contains_set(&a_to_d)); // contains all /// assert!(!example.contains_set(&f_to_t)); // contains none /// assert!(!example.contains_set(&r_to_x)); // contains some @@ -668,9 +686,10 @@ impl<'data> CodePointInversionList<'data> { /// ``` /// use icu::collections::codepointinvlist::CodePointInversionList; /// let example_list = [0x41, 0x44]; // {A, B, C} - /// let example = - /// CodePointInversionList::try_from_u32_inversion_list_slice(&example_list) - /// .unwrap(); + /// let example = CodePointInversionList::try_from_u32_inversion_list_slice( + /// &example_list, + /// ) + /// .unwrap(); /// assert_eq!(example.span("CABXYZ", true), 3); /// assert_eq!(example.span("XYZC", false), 3); /// assert_eq!(example.span("XYZ", true), 0); @@ -691,9 +710,10 @@ impl<'data> CodePointInversionList<'data> { /// ``` /// use icu::collections::codepointinvlist::CodePointInversionList; /// let example_list = [0x41, 0x44]; // {A, B, C} - /// let example = - /// CodePointInversionList::try_from_u32_inversion_list_slice(&example_list) - /// .unwrap(); + /// let example = CodePointInversionList::try_from_u32_inversion_list_slice( + /// &example_list, + /// ) + /// .unwrap(); /// assert_eq!(example.span_back("XYZCAB", true), 3); /// assert_eq!(example.span_back("ABCXYZ", true), 6); /// assert_eq!(example.span_back("CABXYZ", false), 3); diff --git a/components/datetime/src/combo.rs b/components/datetime/src/combo.rs index 9f92d8ecd73..1f5a5762484 100644 --- a/components/datetime/src/combo.rs +++ b/components/datetime/src/combo.rs @@ -40,10 +40,9 @@ use crate::{provider::neo::*, scaffold::*}; /// ) /// .unwrap(); /// -/// let zdt = IxdtfParser::new().try_location_only_from_str( -/// "2024-10-18T15:44[America/Los_Angeles]", -/// ) -/// .unwrap(); +/// let zdt = IxdtfParser::new() +/// .try_location_only_from_str("2024-10-18T15:44[America/Los_Angeles]") +/// .unwrap(); /// /// assert_writeable_eq!( /// formatter.format_any_calendar(&zdt), @@ -68,11 +67,10 @@ use crate::{provider::neo::*, scaffold::*}; /// ) /// .unwrap(); /// -/// let zdt = IxdtfParser::new().try_location_only_iso_from_str( -/// "2024-10-18T15:44[America/Los_Angeles]", -/// ) -/// .unwrap() -/// .to_calendar(Gregorian); +/// let zdt = IxdtfParser::new() +/// .try_location_only_iso_from_str("2024-10-18T15:44[America/Los_Angeles]") +/// .unwrap() +/// .to_calendar(Gregorian); /// /// assert_writeable_eq!( /// formatter.format(&zdt), @@ -84,7 +82,7 @@ use crate::{provider::neo::*, scaffold::*}; /// with a static time zone: /// /// ``` -/// use icu::datetime::fieldsets::{Combo, YMD, Vs, enums::DateFieldSet}; +/// use icu::datetime::fieldsets::{enums::DateFieldSet, Combo, Vs, YMD}; /// use icu::datetime::DateTimeFormatter; /// use icu::locale::locale; /// use icu::timezone::IxdtfParser; @@ -97,10 +95,9 @@ use crate::{provider::neo::*, scaffold::*}; /// ) /// .unwrap(); /// -/// let zdt = IxdtfParser::new().try_location_only_from_str( -/// "2024-10-18T15:44[America/Los_Angeles]", -/// ) -/// .unwrap(); +/// let zdt = IxdtfParser::new() +/// .try_location_only_from_str("2024-10-18T15:44[America/Los_Angeles]") +/// .unwrap(); /// /// assert_writeable_eq!( /// formatter.format_any_calendar(&zdt), diff --git a/components/datetime/src/dynamic.rs b/components/datetime/src/dynamic.rs index b8e8fb313f6..3d4dc14b216 100644 --- a/components/datetime/src/dynamic.rs +++ b/components/datetime/src/dynamic.rs @@ -38,20 +38,26 @@ //! fn get_field_set(should_display_time: bool) -> CompositeDateTimeFieldSet { //! if should_display_time { //! let field_set = fieldsets::MDT::medium().hm(); -//! CompositeDateTimeFieldSet::DateTime(fieldsets::enums::DateAndTimeFieldSet::MDT(field_set)) +//! CompositeDateTimeFieldSet::DateTime( +//! fieldsets::enums::DateAndTimeFieldSet::MDT(field_set), +//! ) //! } else { //! let field_set = fieldsets::MD::medium(); -//! CompositeDateTimeFieldSet::Date(fieldsets::enums::DateFieldSet::MD(field_set)) +//! CompositeDateTimeFieldSet::Date(fieldsets::enums::DateFieldSet::MD( +//! field_set, +//! )) //! } //! } //! //! let datetime = DateTime::try_new_iso(2025, 1, 15, 16, 0, 0).unwrap(); //! -//! let results = [true, false].map(get_field_set).map(|field_set| { -//! DateTimeFormatter::try_new(locale!("en-US").into(), field_set).unwrap() -//! }).map(|formatter| { -//! formatter.format_any_calendar(&datetime).to_string() -//! }); +//! let results = [true, false] +//! .map(get_field_set) +//! .map(|field_set| { +//! DateTimeFormatter::try_new(locale!("en-US").into(), field_set) +//! .unwrap() +//! }) +//! .map(|formatter| formatter.format_any_calendar(&datetime).to_string()); //! //! assert_eq!(results, ["Jan 15, 4:00 PM", "Jan 15"]) //! ``` diff --git a/components/datetime/src/neo.rs b/components/datetime/src/neo.rs index bc202643579..988877f82a0 100644 --- a/components/datetime/src/neo.rs +++ b/components/datetime/src/neo.rs @@ -155,7 +155,6 @@ size_test!(FixedCalendarDateTimeFormatter { @@ -371,7 +370,6 @@ size_test!( /// a calendar selected at runtime. /// /// For more details, please read the [crate root docs][crate]. -/// #[doc = neo_year_month_day_formatter_size!()] #[derive(Debug)] pub struct DateTimeFormatter { @@ -414,8 +412,11 @@ where /// use std::str::FromStr; /// use writeable::assert_writeable_eq; /// - /// let formatter = - /// DateTimeFormatter::try_new(locale!("en-u-ca-hebrew").into(), YMD::medium()).unwrap(); + /// let formatter = DateTimeFormatter::try_new( + /// locale!("en-u-ca-hebrew").into(), + /// YMD::medium(), + /// ) + /// .unwrap(); /// /// let datetime = DateTime::try_new_iso(2024, 5, 8, 0, 0, 0).unwrap(); /// @@ -618,10 +619,7 @@ where /// /// let date = Date::try_new_roc(113, 5, 8).unwrap(); /// - /// assert_writeable_eq!( - /// formatter.format_any_calendar(&date), - /// "30 Nisan 5784" - /// ); + /// assert_writeable_eq!(formatter.format_any_calendar(&date), "30 Nisan 5784"); /// ``` /// /// A time cannot be passed into the formatter when a date is expected: diff --git a/components/datetime/src/neo_serde.rs b/components/datetime/src/neo_serde.rs index d9fe3f75636..80907697080 100644 --- a/components/datetime/src/neo_serde.rs +++ b/components/datetime/src/neo_serde.rs @@ -53,7 +53,8 @@ pub enum CompositeFieldSetSerdeError { /// use icu::datetime::fieldsets::enums::DateFieldSet; /// use icu::datetime::fieldsets::serde::CompositeFieldSetSerde; /// -/// let field_set = CompositeFieldSet::Date(DateFieldSet::YMD(fieldsets::YMD::short())); +/// let field_set = +/// CompositeFieldSet::Date(DateFieldSet::YMD(fieldsets::YMD::short())); /// let serde_input = CompositeFieldSetSerde::from(field_set); /// /// let json_string = serde_json::to_string(&serde_input).unwrap(); @@ -62,7 +63,8 @@ pub enum CompositeFieldSetSerdeError { /// r#"{"fieldSet":["year","month","day"],"length":"short"}"# /// ); /// -/// let serde_output = serde_json::from_str::(&json_string).unwrap(); +/// let serde_output = +/// serde_json::from_str::(&json_string).unwrap(); /// let deserialized = CompositeFieldSet::try_from(serde_output).unwrap(); /// /// assert_eq!(field_set, deserialized); @@ -76,7 +78,8 @@ pub enum CompositeFieldSetSerdeError { /// use icu::datetime::fieldsets::serde::CompositeFieldSetSerdeError; /// /// let json_string = r#"{"fieldSet":["year","time"],"length":"short"}"#; -/// let serde_output = serde_json::from_str::(&json_string).unwrap(); +/// let serde_output = +/// serde_json::from_str::(&json_string).unwrap(); /// /// assert!(matches!( /// CompositeFieldSet::try_from(serde_output), diff --git a/components/datetime/src/options/mod.rs b/components/datetime/src/options/mod.rs index b6ac95be940..e601d9400c7 100644 --- a/components/datetime/src/options/mod.rs +++ b/components/datetime/src/options/mod.rs @@ -25,26 +25,23 @@ use crate::neo_serde::TimePrecisionSerde; /// use icu::locale::locale; /// use writeable::assert_writeable_eq; /// -/// let short_formatter = -/// FixedCalendarDateTimeFormatter::try_new( -/// locale!("en-US").into(), -/// YMD::short(), -/// ) -/// .unwrap(); +/// let short_formatter = FixedCalendarDateTimeFormatter::try_new( +/// locale!("en-US").into(), +/// YMD::short(), +/// ) +/// .unwrap(); /// -/// let medium_formatter = -/// FixedCalendarDateTimeFormatter::try_new( -/// locale!("en-US").into(), -/// YMD::medium(), -/// ) -/// .unwrap(); +/// let medium_formatter = FixedCalendarDateTimeFormatter::try_new( +/// locale!("en-US").into(), +/// YMD::medium(), +/// ) +/// .unwrap(); /// -/// let long_formatter = -/// FixedCalendarDateTimeFormatter::try_new( -/// locale!("en-US").into(), -/// YMD::long(), -/// ) -/// .unwrap(); +/// let long_formatter = FixedCalendarDateTimeFormatter::try_new( +/// locale!("en-US").into(), +/// YMD::long(), +/// ) +/// .unwrap(); /// /// assert_writeable_eq!( /// short_formatter.format(&Date::try_new_gregorian(2000, 1, 1).unwrap()), @@ -338,7 +335,8 @@ impl IntoOption for YearStyle { /// TimePrecision::MinuteExact, /// TimePrecision::SecondPlus, /// TimePrecision::SecondExact(FractionalSecondDigits::F0), -/// ].map(|time_precision| { +/// ] +/// .map(|time_precision| { /// FixedCalendarDateTimeFormatter::<(), _>::try_new( /// locale!("en-US").into(), /// T::short().with_time_precision(time_precision), @@ -356,15 +354,19 @@ impl IntoOption for YearStyle { /// let expected_value_table = [ /// // 7:00:00, 7:00:10, 7:12:20.5432 /// ["7 AM", "7:00:10 AM", "7:12:20 AM"], // HourPlus -/// ["7 AM", "7 AM", "7 AM"], // HourExact +/// ["7 AM", "7 AM", "7 AM"], // HourExact /// ["7:00 AM", "7:00:10 AM", "7:12:20 AM"], // MinutePlus -/// ["7:00 AM", "7:00 AM", "7:12 AM"], // MinuteExact +/// ["7:00 AM", "7:00 AM", "7:12 AM"], // MinuteExact /// ["7:00:00 AM", "7:00:10 AM", "7:12:20 AM"], // SecondPlus /// ["7:00:00 AM", "7:00:10 AM", "7:12:20 AM"], // SecondExact /// ]; /// -/// for (expected_value_row, formatter) in expected_value_table.iter().zip(formatters.iter()) { -/// for (expected_value, time) in expected_value_row.iter().zip(times.iter()) { +/// for (expected_value_row, formatter) in +/// expected_value_table.iter().zip(formatters.iter()) +/// { +/// for (expected_value, time) in +/// expected_value_row.iter().zip(times.iter()) +/// { /// assert_writeable_eq!( /// formatter.format(time), /// *expected_value, @@ -467,7 +469,9 @@ impl IntoOption for TimePrecision { /// /// let formatter = FixedCalendarDateTimeFormatter::<(), _>::try_new( /// locale!("en-US").into(), -/// T::short().with_time_precision(TimePrecision::SecondExact(FractionalSecondDigits::F2)), +/// T::short().with_time_precision(TimePrecision::SecondExact( +/// FractionalSecondDigits::F2, +/// )), /// ) /// .unwrap(); /// diff --git a/components/datetime/src/pattern/formatter.rs b/components/datetime/src/pattern/formatter.rs index f601f14a3cd..4ecf5d3345e 100644 --- a/components/datetime/src/pattern/formatter.rs +++ b/components/datetime/src/pattern/formatter.rs @@ -118,9 +118,7 @@ where /// // Create an instance that can format abbreviated day periods: /// let mut names: TypedDateTimeNames = /// TypedDateTimeNames::try_new(locale!("en-US").into()).unwrap(); - /// names - /// .include_day_period_names(FieldLength::Three) - /// .unwrap(); + /// names.include_day_period_names(FieldLength::Three).unwrap(); /// /// // Create a pattern from a pattern string: /// let pattern_str = "'The time is:' h:mm b"; @@ -144,7 +142,9 @@ where /// "The time is: 12:00 noon" /// ); /// assert_try_writeable_eq!( - /// names.with_pattern_unchecked(&pattern).format(&time_midnight), + /// names + /// .with_pattern_unchecked(&pattern) + /// .format(&time_midnight), /// "The time is: 12:00 midnight" /// ); /// ``` @@ -153,29 +153,26 @@ where /// /// ``` /// use icu::calendar::Gregorian; - /// use icu::datetime::pattern::DateTimePattern; /// use icu::datetime::fieldsets::enums::ZoneFieldSet; + /// use icu::datetime::pattern::DateTimePattern; /// use icu::datetime::pattern::TypedDateTimeNames; /// use icu::locale::locale; /// use icu::timezone::IxdtfParser; /// use writeable::assert_try_writeable_eq; /// - /// let mut london_winter = IxdtfParser::new().try_from_str( - /// "2024-01-01T00:00:00+00:00[Europe/London]", - /// ) - /// .unwrap() - /// .to_calendar(Gregorian); - /// let mut london_summer = IxdtfParser::new().try_from_str( - /// "2024-07-01T00:00:00+01:00[Europe/London]", - /// ) - /// .unwrap() - /// .to_calendar(Gregorian); + /// let mut london_winter = IxdtfParser::new() + /// .try_from_str("2024-01-01T00:00:00+00:00[Europe/London]") + /// .unwrap() + /// .to_calendar(Gregorian); + /// let mut london_summer = IxdtfParser::new() + /// .try_from_str("2024-07-01T00:00:00+01:00[Europe/London]") + /// .unwrap() + /// .to_calendar(Gregorian); /// - /// let mut names = - /// TypedDateTimeNames::::try_new( - /// locale!("en-GB").into(), - /// ) - /// .unwrap(); + /// let mut names = TypedDateTimeNames::::try_new( + /// locale!("en-GB").into(), + /// ) + /// .unwrap(); /// /// names.include_time_zone_essentials().unwrap(); /// names.include_time_zone_specific_short_names().unwrap(); @@ -185,11 +182,15 @@ where /// let pattern: DateTimePattern = pattern_str.parse().unwrap(); /// /// assert_try_writeable_eq!( - /// names.with_pattern_unchecked(&pattern).format(&london_winter), + /// names + /// .with_pattern_unchecked(&pattern) + /// .format(&london_winter), /// "Your time zone is: GMT", /// ); /// assert_try_writeable_eq!( - /// names.with_pattern_unchecked(&pattern).format(&london_summer), + /// names + /// .with_pattern_unchecked(&pattern) + /// .format(&london_summer), /// "Your time zone is: BST", /// ); /// ``` diff --git a/components/datetime/src/pattern/names.rs b/components/datetime/src/pattern/names.rs index 416dd016cd3..5227a5fe40f 100644 --- a/components/datetime/src/pattern/names.rs +++ b/components/datetime/src/pattern/names.rs @@ -46,7 +46,6 @@ size_test!( /// A low-level type that formats datetime patterns with localized names. /// The calendar should be chosen at compile time. -/// #[doc = typed_date_time_names_size!()] /// /// Type parameters: @@ -645,29 +644,26 @@ impl TypedDateTimeNames { /// /// ``` /// use icu::calendar::Gregorian; - /// use icu::datetime::pattern::DateTimePattern; /// use icu::datetime::fieldsets::enums::ZoneFieldSet; + /// use icu::datetime::pattern::DateTimePattern; /// use icu::datetime::pattern::TypedDateTimeNames; /// use icu::locale::locale; /// use icu::timezone::IxdtfParser; /// use writeable::assert_try_writeable_eq; /// - /// let mut zone_london_winter = IxdtfParser::new().try_from_str( - /// "2024-01-01T00:00:00+00:00[Europe/London]", - /// ) - /// .unwrap() - /// .zone; - /// let mut zone_london_summer = IxdtfParser::new().try_from_str( - /// "2024-07-01T00:00:00+01:00[Europe/London]", + /// let mut zone_london_winter = IxdtfParser::new() + /// .try_from_str("2024-01-01T00:00:00+00:00[Europe/London]") + /// .unwrap() + /// .zone; + /// let mut zone_london_summer = IxdtfParser::new() + /// .try_from_str("2024-07-01T00:00:00+01:00[Europe/London]") + /// .unwrap() + /// .zone; + /// + /// let mut names = TypedDateTimeNames::::try_new( + /// locale!("en-GB").into(), /// ) - /// .unwrap() - /// .zone; - /// - /// let mut names = - /// TypedDateTimeNames::::try_new( - /// locale!("en-GB").into(), - /// ) - /// .unwrap(); + /// .unwrap(); /// /// names.include_time_zone_essentials().unwrap(); /// @@ -676,11 +672,15 @@ impl TypedDateTimeNames { /// let pattern: DateTimePattern = pattern_str.parse().unwrap(); /// /// assert_try_writeable_eq!( - /// names.with_pattern_unchecked(&pattern).format(&zone_london_winter), + /// names + /// .with_pattern_unchecked(&pattern) + /// .format(&zone_london_winter), /// "Your time zone is: GMT", /// ); /// assert_try_writeable_eq!( - /// names.with_pattern_unchecked(&pattern).format(&zone_london_summer), + /// names + /// .with_pattern_unchecked(&pattern) + /// .format(&zone_london_summer), /// "Your time zone is: GMT+01:00", /// ); /// @@ -689,7 +689,9 @@ impl TypedDateTimeNames { /// let pattern: DateTimePattern = pattern_str.parse().unwrap(); /// /// assert_try_writeable_eq!( - /// names.with_pattern_unchecked(&pattern).format(&zone_london_winter), + /// names + /// .with_pattern_unchecked(&pattern) + /// .format(&zone_london_winter), /// "Your time zone is: gblon", /// ); /// @@ -698,7 +700,9 @@ impl TypedDateTimeNames { /// let pattern: DateTimePattern = pattern_str.parse().unwrap(); /// /// assert_try_writeable_eq!( - /// names.with_pattern_unchecked(&pattern).format(&zone_london_winter), + /// names + /// .with_pattern_unchecked(&pattern) + /// .format(&zone_london_winter), /// "Your time zone is: +0000", /// ); /// @@ -707,11 +711,15 @@ impl TypedDateTimeNames { /// let pattern: DateTimePattern = pattern_str.parse().unwrap(); /// /// assert_try_writeable_eq!( - /// names.with_pattern_unchecked(&pattern).format(&zone_london_winter), + /// names + /// .with_pattern_unchecked(&pattern) + /// .format(&zone_london_winter), /// "Your time zone is: Z", /// ); /// assert_try_writeable_eq!( - /// names.with_pattern_unchecked(&pattern).format(&zone_london_summer), + /// names + /// .with_pattern_unchecked(&pattern) + /// .format(&zone_london_summer), /// "Your time zone is: +01:00", /// ); /// ``` @@ -748,24 +756,22 @@ impl TypedDateTimeNames { /// /// ``` /// use icu::calendar::Gregorian; - /// use icu::datetime::pattern::DateTimePattern; /// use icu::datetime::fieldsets::enums::ZoneFieldSet; + /// use icu::datetime::pattern::DateTimePattern; /// use icu::datetime::pattern::TypedDateTimeNames; /// use icu::locale::locale; /// use icu::timezone::IxdtfParser; /// use writeable::assert_try_writeable_eq; /// - /// let mut zone_london_winter = IxdtfParser::new().try_from_str( - /// "2024-01-01T00:00:00+00:00[Europe/London]", - /// ) - /// .unwrap() - /// .zone; + /// let mut zone_london_winter = IxdtfParser::new() + /// .try_from_str("2024-01-01T00:00:00+00:00[Europe/London]") + /// .unwrap() + /// .zone; /// - /// let mut names = - /// TypedDateTimeNames::::try_new( - /// locale!("en-GB").into(), - /// ) - /// .unwrap(); + /// let mut names = TypedDateTimeNames::::try_new( + /// locale!("en-GB").into(), + /// ) + /// .unwrap(); /// /// names.include_time_zone_essentials().unwrap(); /// names.include_time_zone_location_names().unwrap(); @@ -775,7 +781,9 @@ impl TypedDateTimeNames { /// let pattern: DateTimePattern = pattern_str.parse().unwrap(); /// /// assert_try_writeable_eq!( - /// names.with_pattern_unchecked(&pattern).format(&zone_london_winter), + /// names + /// .with_pattern_unchecked(&pattern) + /// .format(&zone_london_winter), /// "Your time zone is: UK Time", /// ); /// ``` @@ -815,29 +823,26 @@ impl TypedDateTimeNames { /// /// ``` /// use icu::calendar::Gregorian; - /// use icu::datetime::pattern::DateTimePattern; /// use icu::datetime::fieldsets::enums::ZoneFieldSet; + /// use icu::datetime::pattern::DateTimePattern; /// use icu::datetime::pattern::TypedDateTimeNames; /// use icu::locale::locale; /// use icu::timezone::IxdtfParser; /// use writeable::assert_try_writeable_eq; /// - /// let mut zone_london_winter = IxdtfParser::new().try_from_str( - /// "2024-01-01T00:00:00+00:00[Europe/London]", - /// ) - /// .unwrap() - /// .zone; - /// let mut zone_london_summer = IxdtfParser::new().try_from_str( - /// "2024-07-01T00:00:00+01:00[Europe/London]", + /// let mut zone_london_winter = IxdtfParser::new() + /// .try_from_str("2024-01-01T00:00:00+00:00[Europe/London]") + /// .unwrap() + /// .zone; + /// let mut zone_london_summer = IxdtfParser::new() + /// .try_from_str("2024-07-01T00:00:00+01:00[Europe/London]") + /// .unwrap() + /// .zone; + /// + /// let mut names = TypedDateTimeNames::::try_new( + /// locale!("en-GB").into(), /// ) - /// .unwrap() - /// .zone; - /// - /// let mut names = - /// TypedDateTimeNames::::try_new( - /// locale!("en-GB").into(), - /// ) - /// .unwrap(); + /// .unwrap(); /// /// names.include_time_zone_essentials().unwrap(); /// names.include_time_zone_generic_long_names().unwrap(); @@ -847,11 +852,15 @@ impl TypedDateTimeNames { /// let pattern: DateTimePattern = pattern_str.parse().unwrap(); /// /// assert_try_writeable_eq!( - /// names.with_pattern_unchecked(&pattern).format(&zone_london_winter), + /// names + /// .with_pattern_unchecked(&pattern) + /// .format(&zone_london_winter), /// "Your time zone is: Greenwich Mean Time", /// ); /// assert_try_writeable_eq!( - /// names.with_pattern_unchecked(&pattern).format(&zone_london_summer), + /// names + /// .with_pattern_unchecked(&pattern) + /// .format(&zone_london_summer), /// "Your time zone is: Greenwich Mean Time", // TODO /// ); /// ``` @@ -891,29 +900,26 @@ impl TypedDateTimeNames { /// /// ``` /// use icu::calendar::Gregorian; - /// use icu::datetime::pattern::DateTimePattern; /// use icu::datetime::fieldsets::enums::ZoneFieldSet; + /// use icu::datetime::pattern::DateTimePattern; /// use icu::datetime::pattern::TypedDateTimeNames; /// use icu::locale::locale; /// use icu::timezone::IxdtfParser; /// use writeable::assert_try_writeable_eq; /// - /// let mut zone_london_winter = IxdtfParser::new().try_from_str( - /// "2024-01-01T00:00:00+00:00[Europe/London]", + /// let mut zone_london_winter = IxdtfParser::new() + /// .try_from_str("2024-01-01T00:00:00+00:00[Europe/London]") + /// .unwrap() + /// .zone; + /// let mut zone_london_summer = IxdtfParser::new() + /// .try_from_str("2024-07-01T00:00:00+01:00[Europe/London]") + /// .unwrap() + /// .zone; + /// + /// let mut names = TypedDateTimeNames::::try_new( + /// locale!("en-GB").into(), /// ) - /// .unwrap() - /// .zone; - /// let mut zone_london_summer = IxdtfParser::new().try_from_str( - /// "2024-07-01T00:00:00+01:00[Europe/London]", - /// ) - /// .unwrap() - /// .zone; - /// - /// let mut names = - /// TypedDateTimeNames::::try_new( - /// locale!("en-GB").into(), - /// ) - /// .unwrap(); + /// .unwrap(); /// /// names.include_time_zone_essentials().unwrap(); /// names.include_time_zone_generic_short_names().unwrap(); @@ -923,11 +929,15 @@ impl TypedDateTimeNames { /// let pattern: DateTimePattern = pattern_str.parse().unwrap(); /// /// assert_try_writeable_eq!( - /// names.with_pattern_unchecked(&pattern).format(&zone_london_winter), + /// names + /// .with_pattern_unchecked(&pattern) + /// .format(&zone_london_winter), /// "Your time zone is: GMT", /// ); /// assert_try_writeable_eq!( - /// names.with_pattern_unchecked(&pattern).format(&zone_london_summer), + /// names + /// .with_pattern_unchecked(&pattern) + /// .format(&zone_london_summer), /// "Your time zone is: GMT", // TODO /// ); /// ``` @@ -967,29 +977,26 @@ impl TypedDateTimeNames { /// /// ``` /// use icu::calendar::Gregorian; - /// use icu::datetime::pattern::DateTimePattern; /// use icu::datetime::fieldsets::enums::ZoneFieldSet; + /// use icu::datetime::pattern::DateTimePattern; /// use icu::datetime::pattern::TypedDateTimeNames; /// use icu::locale::locale; /// use icu::timezone::IxdtfParser; /// use writeable::assert_try_writeable_eq; /// - /// let mut zone_london_winter = IxdtfParser::new().try_from_str( - /// "2024-01-01T00:00:00+00:00[Europe/London]", - /// ) - /// .unwrap() - /// .zone; - /// let mut zone_london_summer = IxdtfParser::new().try_from_str( - /// "2024-07-01T00:00:00+01:00[Europe/London]", + /// let mut zone_london_winter = IxdtfParser::new() + /// .try_from_str("2024-01-01T00:00:00+00:00[Europe/London]") + /// .unwrap() + /// .zone; + /// let mut zone_london_summer = IxdtfParser::new() + /// .try_from_str("2024-07-01T00:00:00+01:00[Europe/London]") + /// .unwrap() + /// .zone; + /// + /// let mut names = TypedDateTimeNames::::try_new( + /// locale!("en-GB").into(), /// ) - /// .unwrap() - /// .zone; - /// - /// let mut names = - /// TypedDateTimeNames::::try_new( - /// locale!("en-GB").into(), - /// ) - /// .unwrap(); + /// .unwrap(); /// /// names.include_time_zone_essentials().unwrap(); /// names.include_time_zone_specific_long_names().unwrap(); @@ -999,11 +1006,15 @@ impl TypedDateTimeNames { /// let pattern: DateTimePattern = pattern_str.parse().unwrap(); /// /// assert_try_writeable_eq!( - /// names.with_pattern_unchecked(&pattern).format(&zone_london_winter), + /// names + /// .with_pattern_unchecked(&pattern) + /// .format(&zone_london_winter), /// "Your time zone is: Greenwich Mean Time", /// ); /// assert_try_writeable_eq!( - /// names.with_pattern_unchecked(&pattern).format(&zone_london_summer), + /// names + /// .with_pattern_unchecked(&pattern) + /// .format(&zone_london_summer), /// "Your time zone is: British Summer Time", /// ); /// ``` @@ -1043,29 +1054,26 @@ impl TypedDateTimeNames { /// /// ``` /// use icu::calendar::Gregorian; - /// use icu::datetime::pattern::DateTimePattern; /// use icu::datetime::fieldsets::enums::ZoneFieldSet; + /// use icu::datetime::pattern::DateTimePattern; /// use icu::datetime::pattern::TypedDateTimeNames; /// use icu::locale::locale; /// use icu::timezone::IxdtfParser; /// use writeable::assert_try_writeable_eq; /// - /// let mut zone_london_winter = IxdtfParser::new().try_from_str( - /// "2024-01-01T00:00:00+00:00[Europe/London]", + /// let mut zone_london_winter = IxdtfParser::new() + /// .try_from_str("2024-01-01T00:00:00+00:00[Europe/London]") + /// .unwrap() + /// .zone; + /// let mut zone_london_summer = IxdtfParser::new() + /// .try_from_str("2024-07-01T00:00:00+01:00[Europe/London]") + /// .unwrap() + /// .zone; + /// + /// let mut names = TypedDateTimeNames::::try_new( + /// locale!("en-GB").into(), /// ) - /// .unwrap() - /// .zone; - /// let mut zone_london_summer = IxdtfParser::new().try_from_str( - /// "2024-07-01T00:00:00+01:00[Europe/London]", - /// ) - /// .unwrap() - /// .zone; - /// - /// let mut names = - /// TypedDateTimeNames::::try_new( - /// locale!("en-GB").into(), - /// ) - /// .unwrap(); + /// .unwrap(); /// /// names.include_time_zone_essentials().unwrap(); /// names.include_time_zone_specific_short_names().unwrap(); @@ -1075,11 +1083,15 @@ impl TypedDateTimeNames { /// let pattern: DateTimePattern = pattern_str.parse().unwrap(); /// /// assert_try_writeable_eq!( - /// names.with_pattern_unchecked(&pattern).format(&zone_london_winter), + /// names + /// .with_pattern_unchecked(&pattern) + /// .format(&zone_london_winter), /// "Your time zone is: GMT", /// ); /// assert_try_writeable_eq!( - /// names.with_pattern_unchecked(&pattern).format(&zone_london_summer), + /// names + /// .with_pattern_unchecked(&pattern) + /// .format(&zone_london_summer), /// "Your time zone is: BST", /// ); /// ``` @@ -1108,14 +1120,15 @@ impl TypedDateTimeNames { /// /// ``` /// use icu::calendar::Time; - /// use icu::datetime::pattern::DateTimePattern; /// use icu::datetime::fieldsets::enums::TimeFieldSet; + /// use icu::datetime::pattern::DateTimePattern; /// use icu::datetime::pattern::TypedDateTimeNames; /// use icu::locale::locale; /// use writeable::assert_try_writeable_eq; /// /// let mut names = - /// TypedDateTimeNames::<(), TimeFieldSet>::try_new(locale!("bn").into()).unwrap(); + /// TypedDateTimeNames::<(), TimeFieldSet>::try_new(locale!("bn").into()) + /// .unwrap(); /// names.include_fixed_decimal_formatter(); /// /// // Create a pattern for the time, which is all numbers @@ -1212,8 +1225,7 @@ impl TypedDateTimeNames { /// use writeable::assert_try_writeable_eq; /// /// let mut names = - /// TypedDateTimeNames::::try_new(locale!("en").into()) - /// .unwrap(); + /// TypedDateTimeNames::::try_new(locale!("en").into()).unwrap(); /// /// // Create a pattern from a pattern string: /// let pattern_str = "MMM d (EEEE) 'of year' y G 'at' h:mm a"; diff --git a/components/datetime/src/pattern/pattern.rs b/components/datetime/src/pattern/pattern.rs index 3c400766e40..1deb40e77bd 100644 --- a/components/datetime/src/pattern/pattern.rs +++ b/components/datetime/src/pattern/pattern.rs @@ -27,7 +27,6 @@ size_test!(DateTimePattern, date_time_pattern_size, 32); /// 1. Use it to directly format a datetime via [`TypedDateTimeNames`] /// 2. Convert it to a string pattern via [`Writeable`] /// 3. Get the resolved components -/// #[doc = date_time_pattern_size!()] /// /// # Examples @@ -38,9 +37,9 @@ size_test!(DateTimePattern, date_time_pattern_size, 32); /// ``` /// use icu::calendar::Date; /// use icu::calendar::Gregorian; +/// use icu::datetime::fields::components; /// use icu::datetime::fieldsets::YMD; /// use icu::datetime::pattern::DateTimePattern; -/// use icu::datetime::fields::components; /// use icu::datetime::FixedCalendarDateTimeFormatter; /// use icu::locale::locale; /// use writeable::assert_writeable_eq; @@ -58,7 +57,11 @@ size_test!(DateTimePattern, date_time_pattern_size, 32); /// ) /// .unwrap() /// // The pattern can depend on the datetime being formatted. -/// .format(&Date::try_new_iso(2024, 1, 1).unwrap().to_calendar(Gregorian)) +/// .format( +/// &Date::try_new_iso(2024, 1, 1) +/// .unwrap() +/// .to_calendar(Gregorian), +/// ) /// .pattern(); /// assert_writeable_eq!(data_pattern, pattern_str); /// assert_eq!(custom_pattern, data_pattern); diff --git a/components/datetime/src/provider/neo/mod.rs b/components/datetime/src/provider/neo/mod.rs index d0d7151fc12..c4da4e4cc1b 100644 --- a/components/datetime/src/provider/neo/mod.rs +++ b/components/datetime/src/provider/neo/mod.rs @@ -317,7 +317,6 @@ size_test!(YearNamesV1, year_names_v1_size, 48); /// - 4 is "narrow" /// - 5 is "wide" /// - 6 is "short" (weekdays only) -/// #[doc = year_names_v1_size!()] /// ///
@@ -490,7 +489,6 @@ impl LinearNamesV1<'_> { size_test!(GluePatternV1, glue_pattern_v1_size, 24); /// The default per-length patterns used for combining dates, times, and timezones into formatted strings. -/// #[doc = glue_pattern_v1_size!()] /// ///
diff --git a/components/datetime/src/provider/packed_pattern.rs b/components/datetime/src/provider/packed_pattern.rs index bc67c4e53ec..b0a2a309860 100644 --- a/components/datetime/src/provider/packed_pattern.rs +++ b/components/datetime/src/provider/packed_pattern.rs @@ -42,7 +42,6 @@ pub struct PackedPatternsBuilder<'a> { size_test!(PackedPatternsV1, packed_skeleton_data_size, 32); /// Main data struct for packed datetime patterns. -/// #[doc = packed_skeleton_data_size!()] /// /// ## Variants diff --git a/components/datetime/src/size_test_macro.rs b/components/datetime/src/size_test_macro.rs index f6f8bb760ff..5f407f3a4fd 100644 --- a/components/datetime/src/size_test_macro.rs +++ b/components/datetime/src/size_test_macro.rs @@ -33,7 +33,7 @@ macro_rules! size_test { macro_rules! $id { () => { concat!( - "\n", + "\n\n", "📏 This item has a stack size of ", stringify!($pinned), " bytes on the stable toolchain and ", @@ -65,6 +65,7 @@ macro_rules! size_test { macro_rules! $id { () => { concat!( + "\n\n", "📏 This item has a stack size of ", stringify!($size), " bytes on the stable toolchain at release date." diff --git a/components/decimal/src/lib.rs b/components/decimal/src/lib.rs index ffa65821138..99a6363e958 100644 --- a/components/decimal/src/lib.rs +++ b/components/decimal/src/lib.rs @@ -131,7 +131,6 @@ define_preferences!( /// Read more about the options in the [`options`] module. /// /// See the crate-level documentation for examples. -/// #[doc = fixed_decimal_formatter_size!()] #[derive(Debug)] pub struct FixedDecimalFormatter { diff --git a/components/decimal/src/size_test_macro.rs b/components/decimal/src/size_test_macro.rs index f6f8bb760ff..5f407f3a4fd 100644 --- a/components/decimal/src/size_test_macro.rs +++ b/components/decimal/src/size_test_macro.rs @@ -33,7 +33,7 @@ macro_rules! size_test { macro_rules! $id { () => { concat!( - "\n", + "\n\n", "📏 This item has a stack size of ", stringify!($pinned), " bytes on the stable toolchain and ", @@ -65,6 +65,7 @@ macro_rules! size_test { macro_rules! $id { () => { concat!( + "\n\n", "📏 This item has a stack size of ", stringify!($size), " bytes on the stable toolchain at release date." diff --git a/components/experimental/src/dimension/percent/formatter.rs b/components/experimental/src/dimension/percent/formatter.rs index a1fe31c1794..b67b54dbbea 100644 --- a/components/experimental/src/dimension/percent/formatter.rs +++ b/components/experimental/src/dimension/percent/formatter.rs @@ -114,9 +114,7 @@ impl PercentFormatter { /// /// # Examples /// ``` - /// use icu::experimental::dimension::percent::formatter::{ - /// PercentFormatter, - /// }; + /// use icu::experimental::dimension::percent::formatter::PercentFormatter; /// use icu::locale::locale; /// use writeable::Writeable; /// diff --git a/components/experimental/src/transliterate/transliterator/mod.rs b/components/experimental/src/transliterate/transliterator/mod.rs index 5c22ea22590..5cda2dac650 100644 --- a/components/experimental/src/transliterate/transliterator/mod.rs +++ b/components/experimental/src/transliterate/transliterator/mod.rs @@ -305,26 +305,36 @@ impl Transliterator { /// # Example /// Overriding `"de-t-de-d0-ascii"`'s dependency on `"und-t-und-Latn-d0-ascii"`: /// ``` - /// use icu::experimental::transliterate::{Transliterator, CustomTransliterator}; - /// use icu::locale::Locale; /// use core::ops::Range; + /// use icu::experimental::transliterate::{ + /// CustomTransliterator, Transliterator, + /// }; + /// use icu::locale::Locale; /// /// #[derive(Debug)] /// struct FunkyGermanToAscii; /// impl CustomTransliterator for FunkyGermanToAscii { - /// fn transliterate(&self, input: &str, allowed_range: Range) -> String { + /// fn transliterate( + /// &self, + /// input: &str, + /// allowed_range: Range, + /// ) -> String { /// input[allowed_range].replace("oeverride", "overridden") /// } /// } /// /// let override_locale: Locale = "und-t-und-Latn-d0-ascii".parse().unwrap(); /// let locale = "de-t-de-d0-ascii".parse().unwrap(); - /// let t = Transliterator::try_new_with_override(&locale, |locale| override_locale.eq(locale).then_some(Ok(Box::new(FunkyGermanToAscii)))).unwrap(); + /// let t = Transliterator::try_new_with_override(&locale, |locale| { + /// override_locale + /// .eq(locale) + /// .then_some(Ok(Box::new(FunkyGermanToAscii))) + /// }) + /// .unwrap(); /// let output = t.transliterate("This is an överride example".to_string()); /// /// assert_eq!(output, "This is an overridden example"); /// ``` - /// #[cfg(feature = "compiled_data")] pub fn try_new_with_override(locale: &Locale, lookup: F) -> Result where diff --git a/components/icu/README.md b/components/icu/README.md index c2af2345c25..dae84b25c20 100644 --- a/components/icu/README.md +++ b/components/icu/README.md @@ -28,14 +28,12 @@ provide data explicitly using [`DataProvider`]s. Compiled data is exposed through idiomatic Rust constructors like `new` or `try_new`: ```rust -use icu::datetime::{DateTimeFormatter, Length, fieldsets::YMD}; +use icu::datetime::{fieldsets::YMD, DateTimeFormatter, Length}; use icu::locale::locale; -let dtf = DateTimeFormatter::try_new( - locale!("es-US").into(), - YMD::medium(), -) -.expect("compiled data should include 'es-US'"); +let dtf = + DateTimeFormatter::try_new(locale!("es-US").into(), YMD::medium()) + .expect("compiled data should include 'es-US'"); ``` Clients using compiled data benefit from simple code and optimal zero-cost data loading. Additionally, @@ -51,9 +49,9 @@ Powerful data management is possible with [`DataProvider`]s, which are passed to special constructors: ```rust -use icu::datetime::{DateTimeFormatter, Length, fieldsets::YMD}; -use icu::locale::locale; +use icu::datetime::{fieldsets::YMD, DateTimeFormatter, Length}; use icu::locale::fallback::LocaleFallbacker; +use icu::locale::locale; use icu_provider_adapters::fallback::LocaleFallbackProvider; use icu_provider_blob::BlobDataProvider; @@ -63,7 +61,7 @@ let provider = BlobDataProvider::try_new_from_blob(data) .expect("data should be valid"); let fallbacker = LocaleFallbacker::try_new_with_buffer_provider(&provider) - .expect("provider should include fallback data"); + .expect("provider should include fallback data"); let provider = LocaleFallbackProvider::new(provider, fallbacker); diff --git a/components/icu/src/lib.rs b/components/icu/src/lib.rs index d5a0c514e41..4777bc8b8f7 100644 --- a/components/icu/src/lib.rs +++ b/components/icu/src/lib.rs @@ -28,14 +28,12 @@ //! Compiled data is exposed through idiomatic Rust constructors like `new` or `try_new`: //! //! ``` -//! use icu::datetime::{DateTimeFormatter, Length, fieldsets::YMD}; +//! use icu::datetime::{fieldsets::YMD, DateTimeFormatter, Length}; //! use icu::locale::locale; //! -//! let dtf = DateTimeFormatter::try_new( -//! locale!("es-US").into(), -//! YMD::medium(), -//! ) -//! .expect("compiled data should include 'es-US'"); +//! let dtf = +//! DateTimeFormatter::try_new(locale!("es-US").into(), YMD::medium()) +//! .expect("compiled data should include 'es-US'"); //! ``` //! //! Clients using compiled data benefit from simple code and optimal zero-cost data loading. Additionally, @@ -51,9 +49,9 @@ //! special constructors: //! //! ```no_run -//! use icu::datetime::{DateTimeFormatter, Length, fieldsets::YMD}; -//! use icu::locale::locale; +//! use icu::datetime::{fieldsets::YMD, DateTimeFormatter, Length}; //! use icu::locale::fallback::LocaleFallbacker; +//! use icu::locale::locale; //! use icu_provider_adapters::fallback::LocaleFallbackProvider; //! use icu_provider_blob::BlobDataProvider; //! @@ -63,7 +61,7 @@ //! .expect("data should be valid"); //! //! let fallbacker = LocaleFallbacker::try_new_with_buffer_provider(&provider) -//! .expect("provider should include fallback data"); +//! .expect("provider should include fallback data"); //! //! let provider = LocaleFallbackProvider::new(provider, fallbacker); //! diff --git a/components/list/README.md b/components/list/README.md index f7645ee8299..6fe02d5a139 100644 --- a/components/list/README.md +++ b/components/list/README.md @@ -14,8 +14,7 @@ and as part of the [`icu`](https://docs.rs/icu/latest/icu/) crate. See the latte ```rust let list_formatter = ListFormatter::try_new_and( locale!("es").into(), - ListFormatterOptions::default() - .with_length(ListLength::Wide) + ListFormatterOptions::default().with_length(ListLength::Wide), ) .expect("locale should be present"); @@ -36,8 +35,7 @@ assert_writeable_eq!( ```rust let list_formatter = ListFormatter::try_new_or( locale!("th").into(), - ListFormatterOptions::default() - .with_length(ListLength::Short) + ListFormatterOptions::default().with_length(ListLength::Short), ) .expect("locale should be present"); @@ -50,8 +48,7 @@ assert_writeable_eq!(list_formatter.format(1..=3), "1, 2 หรือ 3",); ```rust let list_formatter = ListFormatter::try_new_unit( locale!("en").into(), - ListFormatterOptions::default() - .with_length(ListLength::Wide) + ListFormatterOptions::default().with_length(ListLength::Wide), ) .expect("locale should be present"); diff --git a/components/list/src/lib.rs b/components/list/src/lib.rs index 69969dc0a52..29cb8a7193d 100644 --- a/components/list/src/lib.rs +++ b/components/list/src/lib.rs @@ -18,8 +18,7 @@ //! # //! let list_formatter = ListFormatter::try_new_and( //! locale!("es").into(), -//! ListFormatterOptions::default() -//! .with_length(ListLength::Wide) +//! ListFormatterOptions::default().with_length(ListLength::Wide), //! ) //! .expect("locale should be present"); //! @@ -44,8 +43,7 @@ //! # //! let list_formatter = ListFormatter::try_new_or( //! locale!("th").into(), -//! ListFormatterOptions::default() -//! .with_length(ListLength::Short) +//! ListFormatterOptions::default().with_length(ListLength::Short), //! ) //! .expect("locale should be present"); //! @@ -62,8 +60,7 @@ //! # //! let list_formatter = ListFormatter::try_new_unit( //! locale!("en").into(), -//! ListFormatterOptions::default() -//! .with_length(ListLength::Wide) +//! ListFormatterOptions::default().with_length(ListLength::Wide), //! ) //! .expect("locale should be present"); //! diff --git a/components/list/src/list_formatter.rs b/components/list/src/list_formatter.rs index a887cdb42f5..54af088525c 100644 --- a/components/list/src/list_formatter.rs +++ b/components/list/src/list_formatter.rs @@ -111,8 +111,7 @@ impl ListFormatter { /// # use writeable::*; /// let formatteur = ListFormatter::try_new_and( /// locale!("fr").into(), - /// ListFormatterOptions::default() - /// .with_length(ListLength::Wide) + /// ListFormatterOptions::default().with_length(ListLength::Wide), /// ) /// .unwrap(); /// let pays = ["Italie", "France", "Espagne", "Allemagne"]; diff --git a/components/list/src/options.rs b/components/list/src/options.rs index 03132457a84..875004fb808 100644 --- a/components/list/src/options.rs +++ b/components/list/src/options.rs @@ -8,8 +8,7 @@ /// ``` /// use icu::list::{ListFormatterOptions, ListLength}; /// -/// let options = ListFormatterOptions::default() -/// .with_length(ListLength::Wide); +/// let options = ListFormatterOptions::default().with_length(ListLength::Wide); /// ``` #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] diff --git a/components/locale/src/directionality.rs b/components/locale/src/directionality.rs index b8007bf9381..51ee19f6a93 100644 --- a/components/locale/src/directionality.rs +++ b/components/locale/src/directionality.rs @@ -169,7 +169,7 @@ impl> LocaleDirectionality { /// /// ``` /// use icu::locale::subtags::script; - /// use icu::locale::{LanguageIdentifier, Direction, LocaleDirectionality}; + /// use icu::locale::{Direction, LanguageIdentifier, LocaleDirectionality}; /// /// let ld = LocaleDirectionality::new(); /// diff --git a/components/locale/src/exemplar_chars.rs b/components/locale/src/exemplar_chars.rs index 4e0c380b700..591935659c8 100644 --- a/components/locale/src/exemplar_chars.rs +++ b/components/locale/src/exemplar_chars.rs @@ -16,8 +16,8 @@ //! # Examples //! //! ``` -//! use icu::locale::locale; //! use icu::locale::exemplar_chars::ExemplarCharacters; +//! use icu::locale::locale; //! //! let locale = locale!("en-001").into(); //! let exemplars_main = ExemplarCharacters::try_new_main(&locale) diff --git a/components/locale/src/fallback/mod.rs b/components/locale/src/fallback/mod.rs index b2fd16dad5d..dc89696d6e3 100644 --- a/components/locale/src/fallback/mod.rs +++ b/components/locale/src/fallback/mod.rs @@ -25,8 +25,8 @@ mod algorithms; /// # Examples /// /// ``` -/// use icu::locale::locale; /// use icu::locale::fallback::LocaleFallbacker; +/// use icu::locale::locale; /// /// // Set up a LocaleFallbacker with data. /// let fallbacker = LocaleFallbacker::new(); diff --git a/components/locale_core/src/extensions/unicode/subdivision.rs b/components/locale_core/src/extensions/unicode/subdivision.rs index 489490abd01..0068bdb69be 100644 --- a/components/locale_core/src/extensions/unicode/subdivision.rs +++ b/components/locale_core/src/extensions/unicode/subdivision.rs @@ -62,8 +62,8 @@ impl_tinystr_subtag!( /// /// ``` /// use icu::locale::{ -/// subtags::region, -/// extensions::unicode::{subdivision_suffix, SubdivisionId} +/// extensions::unicode::{subdivision_suffix, SubdivisionId}, +/// subtags::region, /// }; /// /// let ss = subdivision_suffix!("zzzz"); @@ -89,8 +89,8 @@ impl SubdivisionId { /// /// ``` /// use icu::locale::{ - /// subtags::region, - /// extensions::unicode::{subdivision_suffix, SubdivisionId} + /// extensions::unicode::{subdivision_suffix, SubdivisionId}, + /// subtags::region, /// }; /// /// let ss = subdivision_suffix!("zzzz"); diff --git a/components/locale_core/src/extensions/unicode/value.rs b/components/locale_core/src/extensions/unicode/value.rs index 57ef4808f7b..02c2e9df21b 100644 --- a/components/locale_core/src/extensions/unicode/value.rs +++ b/components/locale_core/src/extensions/unicode/value.rs @@ -73,13 +73,11 @@ impl Value { /// # Examples /// /// ``` - /// use icu::locale::extensions::unicode::Value; /// use core::str::FromStr; + /// use icu::locale::extensions::unicode::Value; /// - /// let value1 = Value::from_str("foo") - /// .expect("failed to parse a Value"); - /// let value2 = Value::from_str("foo-bar") - /// .expect("failed to parse a Value"); + /// let value1 = Value::from_str("foo").expect("failed to parse a Value"); + /// let value2 = Value::from_str("foo-bar").expect("failed to parse a Value"); /// /// assert!(value1.as_single_subtag().is_some()); /// assert!(value2.as_single_subtag().is_none()); @@ -94,13 +92,11 @@ impl Value { /// # Examples /// /// ``` - /// use icu::locale::extensions::unicode::Value; /// use core::str::FromStr; + /// use icu::locale::extensions::unicode::Value; /// - /// let value1 = Value::from_str("foo") - /// .expect("failed to parse a Value"); - /// let value2 = Value::from_str("foo-bar") - /// .expect("failed to parse a Value"); + /// let value1 = Value::from_str("foo").expect("failed to parse a Value"); + /// let value2 = Value::from_str("foo-bar").expect("failed to parse a Value"); /// /// assert!(value1.into_single_subtag().is_some()); /// assert!(value2.into_single_subtag().is_none()); @@ -119,10 +115,7 @@ impl Value { /// # Examples /// /// ``` - /// use icu::locale::{ - /// extensions::unicode::Value, - /// subtags::subtag, - /// }; + /// use icu::locale::{extensions::unicode::Value, subtags::subtag}; /// /// let mut v = Value::default(); /// v.push_subtag(subtag!("foo")); @@ -138,10 +131,7 @@ impl Value { /// # Examples /// /// ``` - /// use icu::locale::{ - /// extensions::unicode::Value, - /// subtags::subtag, - /// }; + /// use icu::locale::{extensions::unicode::Value, subtags::subtag}; /// /// let mut v = Value::default(); /// assert_eq!(v.subtag_count(), 0); @@ -157,10 +147,7 @@ impl Value { /// # Examples /// /// ``` - /// use icu::locale::{ - /// extensions::unicode::Value, - /// subtags::subtag, - /// }; + /// use icu::locale::{extensions::unicode::Value, subtags::subtag}; /// /// let mut v = Value::default(); /// assert_eq!(v.is_empty(), true); @@ -175,10 +162,7 @@ impl Value { /// # Examples /// /// ``` - /// use icu::locale::{ - /// extensions::unicode::Value, - /// subtags::subtag, - /// }; + /// use icu::locale::{extensions::unicode::Value, subtags::subtag}; /// let mut v = Value::default(); /// v.push_subtag(subtag!("foo")); /// v.push_subtag(subtag!("bar")); @@ -201,10 +185,7 @@ impl Value { /// # Examples /// /// ``` - /// use icu::locale::{ - /// extensions::unicode::Value, - /// subtags::subtag, - /// }; + /// use icu::locale::{extensions::unicode::Value, subtags::subtag}; /// let mut v = Value::default(); /// v.push_subtag(subtag!("foo")); /// v.push_subtag(subtag!("bar")); diff --git a/components/locale_core/src/langid.rs b/components/locale_core/src/langid.rs index 8c65af59dcb..a87bc73e329 100644 --- a/components/locale_core/src/langid.rs +++ b/components/locale_core/src/langid.rs @@ -229,12 +229,18 @@ impl LanguageIdentifier { /// "ar-SA", /// ]; /// - /// let mut langids = bcp47_strings.iter().map(|s| s.parse().unwrap()).collect::>(); + /// let mut langids = bcp47_strings + /// .iter() + /// .map(|s| s.parse().unwrap()) + /// .collect::>(); /// langids.sort_by(|a, b| { /// let b = b.write_to_string(); /// a.strict_cmp(b.as_bytes()) /// }); - /// let strict_cmp_strings = langids.iter().map(|l| l.to_string()).collect::>(); + /// let strict_cmp_strings = langids + /// .iter() + /// .map(|l| l.to_string()) + /// .collect::>(); /// /// // Output ordering, sorted alphabetically /// let expected_ordering: &[&str] = &[ @@ -288,9 +294,15 @@ impl LanguageIdentifier { /// ]; /// assert!(bcp47_strings.windows(2).all(|w| w[0] < w[1])); /// - /// let mut langids = bcp47_strings.iter().map(|s| s.parse().unwrap()).collect::>(); + /// let mut langids = bcp47_strings + /// .iter() + /// .map(|s| s.parse().unwrap()) + /// .collect::>(); /// langids.sort_by(LanguageIdentifier::total_cmp); - /// let total_cmp_strings = langids.iter().map(|l| l.to_string()).collect::>(); + /// let total_cmp_strings = langids + /// .iter() + /// .map(|l| l.to_string()) + /// .collect::>(); /// /// // Output ordering, sorted arbitrarily /// let expected_ordering: &[&str] = &[ diff --git a/components/locale_core/src/locale.rs b/components/locale_core/src/locale.rs index f79c8fad350..5b433f1ecac 100644 --- a/components/locale_core/src/locale.rs +++ b/components/locale_core/src/locale.rs @@ -214,12 +214,18 @@ impl Locale { /// "ar-SA", /// ]; /// - /// let mut locales = bcp47_strings.iter().map(|s| s.parse().unwrap()).collect::>(); + /// let mut locales = bcp47_strings + /// .iter() + /// .map(|s| s.parse().unwrap()) + /// .collect::>(); /// locales.sort_by(|a, b| { /// let b = b.write_to_string(); /// a.strict_cmp(b.as_bytes()) /// }); - /// let strict_cmp_strings = locales.iter().map(|l| l.to_string()).collect::>(); + /// let strict_cmp_strings = locales + /// .iter() + /// .map(|l| l.to_string()) + /// .collect::>(); /// /// // Output ordering, sorted alphabetically /// let expected_ordering: &[&str] = &[ @@ -294,9 +300,15 @@ impl Locale { /// ]; /// assert!(bcp47_strings.windows(2).all(|w| w[0] < w[1])); /// - /// let mut locales = bcp47_strings.iter().map(|s| s.parse().unwrap()).collect::>(); + /// let mut locales = bcp47_strings + /// .iter() + /// .map(|s| s.parse().unwrap()) + /// .collect::>(); /// locales.sort_by(Locale::total_cmp); - /// let total_cmp_strings = locales.iter().map(|l| l.to_string()).collect::>(); + /// let total_cmp_strings = locales + /// .iter() + /// .map(|l| l.to_string()) + /// .collect::>(); /// /// // Output ordering, sorted arbitrarily /// let expected_ordering: &[&str] = &[ diff --git a/components/locale_core/src/preferences/extensions/unicode/macros/struct_keyword.rs b/components/locale_core/src/preferences/extensions/unicode/macros/struct_keyword.rs index 06ee503fab4..68004fbd4fd 100644 --- a/components/locale_core/src/preferences/extensions/unicode/macros/struct_keyword.rs +++ b/components/locale_core/src/preferences/extensions/unicode/macros/struct_keyword.rs @@ -8,19 +8,20 @@ /// /// ``` /// use icu::locale::{ -/// preferences::extensions::unicode::struct_keyword, /// extensions::unicode::{Key, Value}, +/// preferences::extensions::unicode::struct_keyword, /// }; /// /// struct_keyword!( /// CurrencyType, /// "cu", /// String, -/// |input: Value| { -/// Ok(Self(input.to_string())) -/// }, +/// |input: Value| { Ok(Self(input.to_string())) }, /// |input: CurrencyType| { -/// icu::locale::extensions::unicode::Value::try_from_str(input.0.as_str()).unwrap() +/// icu::locale::extensions::unicode::Value::try_from_str( +/// input.0.as_str(), +/// ) +/// .unwrap() /// } /// ); /// ``` diff --git a/components/pattern/README.md b/components/pattern/README.md index 449d716eec1..ecc977c902a 100644 --- a/components/pattern/README.md +++ b/components/pattern/README.md @@ -17,8 +17,11 @@ use icu_pattern::SinglePlaceholderPattern; use writeable::assert_writeable_eq; // Parse a pattern string: -let pattern = SinglePlaceholderPattern::try_from_str("Hello, {0}!", Default::default()) - .unwrap(); +let pattern = SinglePlaceholderPattern::try_from_str( + "Hello, {0}!", + Default::default(), +) +.unwrap(); // Interpolate into the pattern string: assert_writeable_eq!(pattern.interpolate(["World"]), "Hello, World!"); diff --git a/components/pattern/src/double.rs b/components/pattern/src/double.rs index 268fad5c0f5..e5129e490fc 100644 --- a/components/pattern/src/double.rs +++ b/components/pattern/src/double.rs @@ -28,8 +28,11 @@ use alloc::{boxed::Box, string::String}; /// use icu_pattern::PatternItem; /// /// // Parse the string syntax -/// let pattern = -/// DoublePlaceholderPattern::try_from_str("Hello, {0} and {1}!", Default::default()).unwrap(); +/// let pattern = DoublePlaceholderPattern::try_from_str( +/// "Hello, {0} and {1}!", +/// Default::default(), +/// ) +/// .unwrap(); /// /// assert_eq!( /// pattern.iter().cmp( @@ -204,9 +207,11 @@ impl DoublePlaceholderInfo { /// use icu_pattern::Pattern; /// /// // Parse the string syntax and check the resulting data store: -/// let pattern = -/// Pattern::::try_from_str("Hello, {0} and {1}!", Default::default()) -/// .unwrap(); +/// let pattern = Pattern::::try_from_str( +/// "Hello, {0} and {1}!", +/// Default::default(), +/// ) +/// .unwrap(); /// /// assert_eq!("\x10\x1BHello, and !", &pattern.store); /// ``` @@ -226,41 +231,56 @@ impl DoublePlaceholderInfo { /// /// // Single numeric placeholder (note, "5" is used): /// assert_eq!( -/// Pattern::::try_from_str("{0} days ago", Default::default()) -/// .unwrap() -/// .interpolate_to_string([5, 7]), +/// Pattern::::try_from_str( +/// "{0} days ago", +/// Default::default() +/// ) +/// .unwrap() +/// .interpolate_to_string([5, 7]), /// "5 days ago", /// ); /// /// // No placeholder (note, the placeholder value is never accessed): /// assert_eq!( -/// Pattern::::try_from_str("yesterday", Default::default()) -/// .unwrap() -/// .interpolate_to_string(["foo", "bar"]), +/// Pattern::::try_from_str( +/// "yesterday", +/// Default::default() +/// ) +/// .unwrap() +/// .interpolate_to_string(["foo", "bar"]), /// "yesterday", /// ); /// /// // Escaped placeholder and a placeholder value 1 (note, "bar" is used): /// assert_eq!( -/// Pattern::::try_from_str("'{0}' {1}", QuoteMode::QuotingSupported.into()) -/// .unwrap() -/// .interpolate_to_string(("foo", "bar")), +/// Pattern::::try_from_str( +/// "'{0}' {1}", +/// QuoteMode::QuotingSupported.into() +/// ) +/// .unwrap() +/// .interpolate_to_string(("foo", "bar")), /// "{0} bar", /// ); /// /// // Pattern with the placeholders in the opposite order: /// assert_eq!( -/// Pattern::::try_from_str("A {1} B {0} C", Default::default()) -/// .unwrap() -/// .interpolate_to_string(("D", "E")), +/// Pattern::::try_from_str( +/// "A {1} B {0} C", +/// Default::default() +/// ) +/// .unwrap() +/// .interpolate_to_string(("D", "E")), /// "A E B D C", /// ); /// /// // No literals, only placeholders: /// assert_eq!( -/// Pattern::::try_from_str("{1}{0}", Default::default()) -/// .unwrap() -/// .interpolate_to_string((1, "A")), +/// Pattern::::try_from_str( +/// "{1}{0}", +/// Default::default() +/// ) +/// .unwrap() +/// .interpolate_to_string((1, "A")), /// "A1", /// ); /// ``` diff --git a/components/pattern/src/frontend/mod.rs b/components/pattern/src/frontend/mod.rs index 5f183d593c4..39a22c6a31f 100644 --- a/components/pattern/src/frontend/mod.rs +++ b/components/pattern/src/frontend/mod.rs @@ -54,8 +54,11 @@ use writeable::{adapters::TryWriteableInfallibleAsWriteable, PartsWrite, TryWrit /// use icu_pattern::SinglePlaceholder; /// use writeable::assert_writeable_parts_eq; /// -/// let pattern = -/// Pattern::::try_from_str("Hello, {0}!", Default::default()).unwrap(); +/// let pattern = Pattern::::try_from_str( +/// "Hello, {0}!", +/// Default::default(), +/// ) +/// .unwrap(); /// /// assert_writeable_parts_eq!( /// pattern.interpolate(["Alice"]), diff --git a/components/pattern/src/lib.rs b/components/pattern/src/lib.rs index 335c29b4143..78b9cad560b 100644 --- a/components/pattern/src/lib.rs +++ b/components/pattern/src/lib.rs @@ -17,8 +17,11 @@ //! use writeable::assert_writeable_eq; //! //! // Parse a pattern string: -//! let pattern = SinglePlaceholderPattern::try_from_str("Hello, {0}!", Default::default()) -//! .unwrap(); +//! let pattern = SinglePlaceholderPattern::try_from_str( +//! "Hello, {0}!", +//! Default::default(), +//! ) +//! .unwrap(); //! //! // Interpolate into the pattern string: //! assert_writeable_eq!(pattern.interpolate(["World"]), "Hello, World!"); @@ -101,7 +104,11 @@ mod private { /// use writeable::assert_writeable_eq; /// /// // Create a pattern from the string syntax: -/// let pattern = SinglePlaceholderPattern::try_from_str("Hello, {0}!", Default::default()).unwrap(); +/// let pattern = SinglePlaceholderPattern::try_from_str( +/// "Hello, {0}!", +/// Default::default(), +/// ) +/// .unwrap(); /// /// // Interpolate some values into the pattern: /// assert_writeable_eq!(pattern.interpolate(["Alice"]), "Hello, Alice!"); @@ -116,8 +123,11 @@ pub type SinglePlaceholderPattern = Pattern; /// use writeable::assert_writeable_eq; /// /// // Create a pattern from the string syntax: -/// let pattern = -/// DoublePlaceholderPattern::try_from_str("Hello, {0} and {1}!", Default::default()).unwrap(); +/// let pattern = DoublePlaceholderPattern::try_from_str( +/// "Hello, {0} and {1}!", +/// Default::default(), +/// ) +/// .unwrap(); /// /// // Interpolate some values into the pattern: /// assert_writeable_eq!( @@ -137,7 +147,8 @@ pub type DoublePlaceholderPattern = Pattern; /// /// // Create a pattern from the string syntax: /// let pattern = MultiNamedPlaceholderPattern::try_from_str( -/// "Hello, {person0} and {person1}!", Default::default() +/// "Hello, {person0} and {person1}!", +/// Default::default(), /// ) /// .unwrap(); /// diff --git a/components/pattern/src/multi_named.rs b/components/pattern/src/multi_named.rs index 533e4ccb0be..ace5e3b2474 100644 --- a/components/pattern/src/multi_named.rs +++ b/components/pattern/src/multi_named.rs @@ -27,7 +27,8 @@ use crate::Error; /// /// // Parse the string syntax and check the resulting data store: /// let pattern = MultiNamedPlaceholderPattern::try_from_str( -/// "Hello, {person0} and {person1}!", Default::default() +/// "Hello, {person0} and {person1}!", +/// Default::default(), /// ) /// .unwrap(); /// @@ -192,28 +193,37 @@ where /// /// // Single placeholder: /// assert_eq!( -/// Pattern::::try_from_str("{num} days ago", Default::default()) -/// .unwrap() -/// .try_interpolate_to_string(&placeholder_value_map) -/// .unwrap(), +/// Pattern::::try_from_str( +/// "{num} days ago", +/// Default::default() +/// ) +/// .unwrap() +/// .try_interpolate_to_string(&placeholder_value_map) +/// .unwrap(), /// "5 days ago", /// ); /// /// // No placeholder (note, the placeholder value is never accessed): /// assert_eq!( -/// Pattern::::try_from_str("yesterday", Default::default()) -/// .unwrap() -/// .try_interpolate_to_string(&placeholder_value_map) -/// .unwrap(), +/// Pattern::::try_from_str( +/// "yesterday", +/// Default::default() +/// ) +/// .unwrap() +/// .try_interpolate_to_string(&placeholder_value_map) +/// .unwrap(), /// "yesterday", /// ); /// /// // No literals, only placeholders: /// assert_eq!( -/// Pattern::::try_from_str("{letter}{num}{}", Default::default()) -/// .unwrap() -/// .try_interpolate_to_string(&placeholder_value_map) -/// .unwrap(), +/// Pattern::::try_from_str( +/// "{letter}{num}{}", +/// Default::default() +/// ) +/// .unwrap() +/// .try_interpolate_to_string(&placeholder_value_map) +/// .unwrap(), /// "X5empty", /// ); /// ``` @@ -255,10 +265,13 @@ where /// let placeholder_value_map: BTreeMap<&str, &str> = /// [("num", "5"), ("letter", "X")].into_iter().collect(); /// -/// Pattern::::try_from_str("Your name is {your_name}", Default::default()) -/// .unwrap() -/// .try_interpolate_to_string(&placeholder_value_map) -/// .unwrap(); +/// Pattern::::try_from_str( +/// "Your name is {your_name}", +/// Default::default(), +/// ) +/// .unwrap() +/// .try_interpolate_to_string(&placeholder_value_map) +/// .unwrap(); /// ``` /// /// Recover the best-effort lossy string by directly using [`Pattern::try_interpolate()`]: @@ -276,7 +289,8 @@ where /// [("num", "5"), ("letter", "X")].into_iter().collect(); /// /// let pattern = Pattern::::try_from_str( -/// "Your name is {your_name}", Default::default(), +/// "Your name is {your_name}", +/// Default::default(), /// ) /// .unwrap(); /// diff --git a/components/pattern/src/single.rs b/components/pattern/src/single.rs index f14fcabdeb2..9f74913b317 100644 --- a/components/pattern/src/single.rs +++ b/components/pattern/src/single.rs @@ -28,7 +28,11 @@ use alloc::{boxed::Box, string::String}; /// use icu_pattern::SinglePlaceholderPattern; /// /// // Parse the string syntax and check the resulting data store: -/// let pattern = SinglePlaceholderPattern::try_from_str("Hello, {0}!", Default::default()).unwrap(); +/// let pattern = SinglePlaceholderPattern::try_from_str( +/// "Hello, {0}!", +/// Default::default(), +/// ) +/// .unwrap(); /// /// assert_eq!( /// pattern.iter().cmp( @@ -118,8 +122,11 @@ where /// use icu_pattern::SinglePlaceholder; /// /// // Parse the string syntax and check the resulting data store: -/// let pattern = Pattern::::try_from_str("Hello, {0}!", Default::default()) -/// .unwrap(); +/// let pattern = Pattern::::try_from_str( +/// "Hello, {0}!", +/// Default::default(), +/// ) +/// .unwrap(); /// /// assert_eq!("\u{8}Hello, !", &pattern.store); /// ``` @@ -129,38 +136,50 @@ where /// ``` /// use core::str::FromStr; /// use icu_pattern::Pattern; -/// use icu_pattern::SinglePlaceholder; /// use icu_pattern::QuoteMode; +/// use icu_pattern::SinglePlaceholder; /// /// // Single numeric placeholder: /// assert_eq!( -/// Pattern::::try_from_str("{0} days ago", Default::default()) -/// .unwrap() -/// .interpolate_to_string([5]), +/// Pattern::::try_from_str( +/// "{0} days ago", +/// Default::default() +/// ) +/// .unwrap() +/// .interpolate_to_string([5]), /// "5 days ago", /// ); /// /// // Single named placeholder: /// assert_eq!( -/// Pattern::::try_from_str("{name}", Default::default()) -/// .unwrap() -/// .interpolate_to_string(["Alice"]), +/// Pattern::::try_from_str( +/// "{name}", +/// Default::default() +/// ) +/// .unwrap() +/// .interpolate_to_string(["Alice"]), /// "Alice", /// ); /// /// // No placeholder (note, the placeholder value is never accessed): /// assert_eq!( -/// Pattern::::try_from_str("yesterday", Default::default()) -/// .unwrap() -/// .interpolate_to_string(["hi"]), +/// Pattern::::try_from_str( +/// "yesterday", +/// Default::default() +/// ) +/// .unwrap() +/// .interpolate_to_string(["hi"]), /// "yesterday", /// ); /// /// // Escaped placeholder and a real placeholder: /// assert_eq!( -/// Pattern::::try_from_str("'{0}' {1}", QuoteMode::QuotingSupported.into()) -/// .unwrap() -/// .interpolate_to_string(("hi",)), +/// Pattern::::try_from_str( +/// "'{0}' {1}", +/// QuoteMode::QuotingSupported.into() +/// ) +/// .unwrap() +/// .interpolate_to_string(("hi",)), /// "{0} hi", /// ); /// ``` diff --git a/components/plurals/README.md b/components/plurals/README.md index 534b030576b..511473cf649 100644 --- a/components/plurals/README.md +++ b/components/plurals/README.md @@ -27,9 +27,8 @@ appropriate [`PluralCategory`]. use icu::locale::locale; use icu::plurals::{PluralCategory, PluralRules}; -let pr = - PluralRules::try_new(locale!("en").into(), Default::default()) - .expect("locale should be present"); +let pr = PluralRules::try_new(locale!("en").into(), Default::default()) + .expect("locale should be present"); assert_eq!(pr.category_for(5_usize), PluralCategory::Other); ``` diff --git a/components/plurals/src/lib.rs b/components/plurals/src/lib.rs index 3e16b7647cc..4cd4f3a547a 100644 --- a/components/plurals/src/lib.rs +++ b/components/plurals/src/lib.rs @@ -27,9 +27,8 @@ //! use icu::locale::locale; //! use icu::plurals::{PluralCategory, PluralRules}; //! -//! let pr = -//! PluralRules::try_new(locale!("en").into(), Default::default()) -//! .expect("locale should be present"); +//! let pr = PluralRules::try_new(locale!("en").into(), Default::default()) +//! .expect("locale should be present"); //! //! assert_eq!(pr.category_for(5_usize), PluralCategory::Other); //! ``` @@ -110,9 +109,8 @@ use provider::UnvalidatedPluralRange; /// use icu::locale::locale; /// use icu::plurals::{PluralCategory, PluralRules}; /// -/// let pr = -/// PluralRules::try_new(locale!("en").into(), Default::default()) -/// .expect("locale should be present"); +/// let pr = PluralRules::try_new(locale!("en").into(), Default::default()) +/// .expect("locale should be present"); /// /// assert_eq!(pr.category_for(5_usize), PluralCategory::Other); /// ``` @@ -249,9 +247,8 @@ define_preferences!( /// use icu::locale::locale; /// use icu::plurals::{PluralCategory, PluralRules}; /// -/// let pr = -/// PluralRules::try_new(locale!("en").into(), Default::default()) -/// .expect("locale should be present"); +/// let pr = PluralRules::try_new(locale!("en").into(), Default::default()) +/// .expect("locale should be present"); /// /// assert_eq!(pr.category_for(5_usize), PluralCategory::Other); /// ``` @@ -416,9 +413,8 @@ impl PluralRules { /// use icu::locale::locale; /// use icu::plurals::{PluralCategory, PluralRules}; /// - /// let pr = - /// PluralRules::try_new(locale!("en").into(), Default::default()) - /// .expect("locale should be present"); + /// let pr = PluralRules::try_new(locale!("en").into(), Default::default()) + /// .expect("locale should be present"); /// /// match pr.category_for(1_usize) { /// PluralCategory::One => "One item", @@ -487,9 +483,8 @@ impl PluralRules { /// use icu::locale::locale; /// use icu::plurals::{PluralCategory, PluralRules}; /// - /// let pr = - /// PluralRules::try_new(locale!("fr").into(), Default::default()) - /// .expect("locale should be present"); + /// let pr = PluralRules::try_new(locale!("fr").into(), Default::default()) + /// .expect("locale should be present"); /// /// let mut categories = pr.categories(); /// assert_eq!(categories.next(), Some(PluralCategory::One)); @@ -536,7 +531,7 @@ impl PluralRules { /// /// ``` /// use icu::locale::locale; -/// use icu::plurals::{PluralRulesWithRanges, PluralCategory, PluralOperands}; +/// use icu::plurals::{PluralCategory, PluralOperands, PluralRulesWithRanges}; /// /// let ranges = PluralRulesWithRanges::try_new( /// locale!("ar").into(), @@ -758,9 +753,7 @@ where /// /// ``` /// use icu::locale::locale; - /// use icu::plurals::{ - /// PluralCategory, PluralOperands, PluralRulesWithRanges, - /// }; + /// use icu::plurals::{PluralCategory, PluralOperands, PluralRulesWithRanges}; /// /// let ranges = PluralRulesWithRanges::try_new( /// locale!("ro").into(), @@ -801,12 +794,14 @@ where /// /// ``` /// use icu::locale::locale; - /// use icu::plurals::{PluralCategory, PluralRuleType, PluralRulesOptions, PluralRulesWithRanges}; + /// use icu::plurals::{ + /// PluralCategory, PluralRuleType, PluralRulesOptions, + /// PluralRulesWithRanges, + /// }; /// /// let ranges = PluralRulesWithRanges::try_new( /// locale!("sl").into(), - /// PluralRulesOptions::default() - /// .with_type(PluralRuleType::Ordinal), + /// PluralRulesOptions::default().with_type(PluralRuleType::Ordinal), /// ) /// .expect("locale should be present"); /// diff --git a/components/plurals/src/options.rs b/components/plurals/src/options.rs index 0182d3beb5d..bd41b7be04c 100644 --- a/components/plurals/src/options.rs +++ b/components/plurals/src/options.rs @@ -6,10 +6,10 @@ /// /// # Examples /// ``` -/// use icu::plurals::{PluralRulesOptions, PluralRuleType}; +/// use icu::plurals::{PluralRuleType, PluralRulesOptions}; /// -/// let options = PluralRulesOptions::default() -/// .with_type(PluralRuleType::Cardinal); +/// let options = +/// PluralRulesOptions::default().with_type(PluralRuleType::Cardinal); /// ``` #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[non_exhaustive] diff --git a/components/properties/src/code_point_map.rs b/components/properties/src/code_point_map.rs index d7dfa761b16..78cf594b300 100644 --- a/components/properties/src/code_point_map.rs +++ b/components/properties/src/code_point_map.rs @@ -174,8 +174,8 @@ impl<'a, T: TrieValue> CodePointMapDataBorrowed<'a, T> { /// # Example /// /// ``` - /// use icu::properties::CodePointMapData; /// use icu::properties::props::GeneralCategory; + /// use icu::properties::CodePointMapData; /// /// let gc = CodePointMapData::::new(); /// @@ -197,8 +197,8 @@ impl<'a, T: TrieValue> CodePointMapDataBorrowed<'a, T> { /// # Examples /// /// ``` - /// use icu::properties::CodePointMapData; /// use icu::properties::props::GeneralCategory; + /// use icu::properties::CodePointMapData; /// /// let gc = CodePointMapData::::new(); /// let mut ranges = gc.iter_ranges(); @@ -220,8 +220,8 @@ impl<'a, T: TrieValue> CodePointMapDataBorrowed<'a, T> { /// /// /// ``` - /// use icu::properties::CodePointMapData; /// use icu::properties::props::GeneralCategory; + /// use icu::properties::CodePointMapData; /// /// let gc = CodePointMapData::::new(); /// let mut ranges = gc.iter_ranges_for_value(GeneralCategory::UppercaseLetter); @@ -313,8 +313,8 @@ impl<'a> CodePointMapDataBorrowed<'a, GeneralCategory> { /// # Examples /// /// ``` - /// use icu::properties::CodePointMapData; /// use icu::properties::props::{GeneralCategory, GeneralCategoryGroup}; + /// use icu::properties::CodePointMapData; /// /// let gc = CodePointMapData::::new(); /// let mut ranges = gc.iter_ranges_for_group(GeneralCategoryGroup::Letter); diff --git a/components/properties/src/code_point_set.rs b/components/properties/src/code_point_set.rs index 13920589632..e9406264491 100644 --- a/components/properties/src/code_point_set.rs +++ b/components/properties/src/code_point_set.rs @@ -158,8 +158,8 @@ impl<'a> CodePointSetDataBorrowed<'a> { /// # Example /// /// ``` - /// use icu::properties::CodePointSetData; /// use icu::properties::props::Alphabetic; + /// use icu::properties::CodePointSetData; /// /// let alphabetic = CodePointSetData::new::(); /// let mut ranges = alphabetic.iter_ranges(); @@ -182,8 +182,8 @@ impl<'a> CodePointSetDataBorrowed<'a> { /// # Example /// /// ``` - /// use icu::properties::CodePointSetData; /// use icu::properties::props::Alphabetic; + /// use icu::properties::CodePointSetData; /// /// let alphabetic = CodePointSetData::new::(); /// let mut ranges = alphabetic.iter_ranges(); diff --git a/components/properties/src/names.rs b/components/properties/src/names.rs index 090243619ae..70abbd891c2 100644 --- a/components/properties/src/names.rs +++ b/components/properties/src/names.rs @@ -25,8 +25,8 @@ use zerotrie::cursor::ZeroTrieSimpleAsciiCursor; /// # Example /// /// ``` -/// use icu::properties::PropertyParser; /// use icu::properties::props::GeneralCategory; +/// use icu::properties::PropertyParser; /// /// let lookup = PropertyParser::::new(); /// // short name for value @@ -134,8 +134,8 @@ impl PropertyParserBorrowed<'_, T> { /// # Example /// /// ``` - /// use icu::properties::PropertyParser; /// use icu::properties::props::GeneralCategory; + /// use icu::properties::PropertyParser; /// /// let lookup = PropertyParser::::new(); /// assert_eq!( @@ -160,8 +160,8 @@ impl PropertyParserBorrowed<'_, T> { /// # Example /// /// ``` - /// use icu::properties::PropertyParser; /// use icu::properties::props::GeneralCategory; + /// use icu::properties::PropertyParser; /// /// let lookup = PropertyParser::::new(); /// assert_eq!( @@ -187,8 +187,8 @@ impl PropertyParserBorrowed<'_, T> { /// # Example /// /// ``` - /// use icu::properties::PropertyParser; /// use icu::properties::props::GeneralCategory; + /// use icu::properties::PropertyParser; /// /// let lookup = PropertyParser::::new(); /// assert_eq!( @@ -217,8 +217,8 @@ impl PropertyParserBorrowed<'_, T> { /// # Example /// /// ``` - /// use icu::properties::PropertyParser; /// use icu::properties::props::GeneralCategory; + /// use icu::properties::PropertyParser; /// /// let lookup = PropertyParser::::new(); /// assert_eq!( @@ -336,8 +336,8 @@ fn get_loose_u16(payload: &PropertyValueNameToEnumMapV1<'_>, name: &str) -> Opti /// # Example /// /// ``` -/// use icu::properties::PropertyNamesLong; /// use icu::properties::props::CanonicalCombiningClass; +/// use icu::properties::PropertyNamesLong; /// /// let names = PropertyNamesLong::::new(); /// assert_eq!( @@ -417,8 +417,8 @@ impl PropertyNamesLongBorrowed<'_, T> { /// # Example /// /// ```rust - /// use icu::properties::PropertyNamesLong; /// use icu::properties::props::CanonicalCombiningClass; + /// use icu::properties::PropertyNamesLong; /// /// let lookup = PropertyNamesLong::::new(); /// assert_eq!( @@ -474,18 +474,12 @@ impl PropertyNamesLongBorrowed<'static, T> { /// # Example /// /// ``` -/// use icu::properties::PropertyNamesShort; /// use icu::properties::props::CanonicalCombiningClass; +/// use icu::properties::PropertyNamesShort; /// /// let names = PropertyNamesShort::::new(); -/// assert_eq!( -/// names.get(CanonicalCombiningClass::KanaVoicing), -/// Some("KV") -/// ); -/// assert_eq!( -/// names.get(CanonicalCombiningClass::AboveLeft), -/// Some("AL") -/// ); +/// assert_eq!(names.get(CanonicalCombiningClass::KanaVoicing), Some("KV")); +/// assert_eq!(names.get(CanonicalCombiningClass::AboveLeft), Some("AL")); /// ``` pub struct PropertyNamesShort { map: DataPayload>, @@ -556,18 +550,12 @@ impl PropertyNamesShortBorrowed<'_, T> { /// # Example /// /// ```rust - /// use icu::properties::PropertyNamesShort; /// use icu::properties::props::CanonicalCombiningClass; + /// use icu::properties::PropertyNamesShort; /// /// let lookup = PropertyNamesShort::::new(); - /// assert_eq!( - /// lookup.get(CanonicalCombiningClass::KanaVoicing), - /// Some("KV") - /// ); - /// assert_eq!( - /// lookup.get(CanonicalCombiningClass::AboveLeft), - /// Some("AL") - /// ); + /// assert_eq!(lookup.get(CanonicalCombiningClass::KanaVoicing), Some("KV")); + /// assert_eq!(lookup.get(CanonicalCombiningClass::AboveLeft), Some("AL")); /// ``` #[inline] pub fn get(&self, property: T) -> Option<&str> { @@ -583,24 +571,36 @@ impl PropertyNamesShortBorrowed<'_, Script> { /// # Example /// /// ```rust - /// use icu::properties::PropertyNamesShort; - /// use icu::properties::props::Script; /// use icu::locale::subtags::script; + /// use icu::properties::props::Script; + /// use icu::properties::PropertyNamesShort; /// /// let lookup = PropertyNamesShort::