From acd012cbf48a25bf632929fd2c0eefc517c853a5 Mon Sep 17 00:00:00 2001 From: Robert Bastian <4706271+robertbastian@users.noreply.github.com> Date: Wed, 15 Nov 2023 16:05:35 +0100 Subject: [PATCH] Format docs (#4301) --- components/plurals/src/lib.rs | 5 ++--- provider/core/src/request.rs | 19 ++++++++++--------- utils/fixed_decimal/src/decimal.rs | 30 +++++++++++++++++++++++++----- utils/litemap/src/databake.rs | 3 ++- utils/zerovec/src/map2d/map.rs | 15 +++------------ 5 files changed, 42 insertions(+), 30 deletions(-) diff --git a/components/plurals/src/lib.rs b/components/plurals/src/lib.rs index f05d79cbbe2..aa734637cff 100644 --- a/components/plurals/src/lib.rs +++ b/components/plurals/src/lib.rs @@ -801,9 +801,8 @@ where /// use icu::locid::locale; /// use icu::plurals::{PluralCategory, PluralRulesWithRanges}; /// - /// let ranges = - /// PluralRulesWithRanges::try_new_cardinal(&locale!("en").into()) - /// .expect("locale should be present"); + /// let ranges = PluralRulesWithRanges::try_new_cardinal(&locale!("en").into()) + /// .expect("locale should be present"); /// /// let rules = ranges.rules(); /// diff --git a/provider/core/src/request.rs b/provider/core/src/request.rs index 44436a0b2b6..1bb84f86675 100644 --- a/provider/core/src/request.rs +++ b/provider/core/src/request.rs @@ -440,10 +440,7 @@ impl DataLocale { /// .parse::() /// .unwrap() /// .is_langid_und()); - /// assert!("und-x-aux" - /// .parse::() - /// .unwrap() - /// .is_langid_und()); + /// assert!("und-x-aux".parse::().unwrap().is_langid_und()); /// assert!(!"ca-ES".parse::().unwrap().is_langid_und()); /// ``` pub fn is_langid_und(&self) -> bool { @@ -871,8 +868,8 @@ impl AuxiliaryKeys { /// # Examples /// /// ``` - /// use icu_provider::prelude::*; /// use icu_locid::extensions::private::subtag; + /// use icu_provider::prelude::*; /// /// // Single auxiliary key: /// let a = AuxiliaryKeys::try_from_iter([subtag!("abc")]).unwrap(); @@ -880,7 +877,8 @@ impl AuxiliaryKeys { /// assert_eq!(a, b); /// /// // Multiple auxiliary keys: - /// let a = AuxiliaryKeys::try_from_iter([subtag!("abc"), subtag!("defg")]).unwrap(); + /// let a = AuxiliaryKeys::try_from_iter([subtag!("abc"), subtag!("defg")]) + /// .unwrap(); /// let b = "abc-defg".parse::().unwrap(); /// assert_eq!(a, b); /// ``` @@ -921,8 +919,8 @@ impl AuxiliaryKeys { /// # Examples /// /// ``` - /// use icu_provider::prelude::*; /// use icu_locid::extensions::private::subtag; + /// use icu_provider::prelude::*; /// /// // Single auxiliary key: /// let a = AuxiliaryKeys::from_subtag(subtag!("abc")); @@ -968,11 +966,14 @@ impl AuxiliaryKeys { /// # Example /// /// ``` - /// use icu_provider::AuxiliaryKeys; /// use icu_locid::extensions::private::subtag; + /// use icu_provider::AuxiliaryKeys; /// /// let aux: AuxiliaryKeys = "abc-defg".parse().unwrap(); - /// assert_eq!(aux.iter().collect::>(), vec![subtag!("abc"), subtag!("defg")]); + /// assert_eq!( + /// aux.iter().collect::>(), + /// vec![subtag!("abc"), subtag!("defg")] + /// ); /// ``` pub fn iter(&self) -> impl Iterator + '_ { self.value diff --git a/utils/fixed_decimal/src/decimal.rs b/utils/fixed_decimal/src/decimal.rs index 7fcc963e04e..12616bc92e0 100644 --- a/utils/fixed_decimal/src/decimal.rs +++ b/utils/fixed_decimal/src/decimal.rs @@ -1166,15 +1166,35 @@ impl FixedDecimal { /// # use std::str::FromStr; /// /// let mut dec = FixedDecimal::from_str("-3.5").unwrap(); - /// assert_eq!("-2", dec.trunced_to_increment(0, RoundingIncrement::MultiplesOf2).to_string()); + /// assert_eq!( + /// "-2", + /// dec.trunced_to_increment(0, RoundingIncrement::MultiplesOf2) + /// .to_string() + /// ); /// let mut dec = FixedDecimal::from_str("7.57").unwrap(); - /// assert_eq!("7.5", dec.trunced_to_increment(-1, RoundingIncrement::MultiplesOf5).to_string()); + /// assert_eq!( + /// "7.5", + /// dec.trunced_to_increment(-1, RoundingIncrement::MultiplesOf5) + /// .to_string() + /// ); /// let mut dec = FixedDecimal::from_str("5.45").unwrap(); - /// assert_eq!("5.25", dec.trunced_to_increment(-2, RoundingIncrement::MultiplesOf25).to_string()); + /// assert_eq!( + /// "5.25", + /// dec.trunced_to_increment(-2, RoundingIncrement::MultiplesOf25) + /// .to_string() + /// ); /// let mut dec = FixedDecimal::from_str("9.99").unwrap(); - /// assert_eq!("7.5", dec.trunced_to_increment(-1, RoundingIncrement::MultiplesOf25).to_string()); + /// assert_eq!( + /// "7.5", + /// dec.trunced_to_increment(-1, RoundingIncrement::MultiplesOf25) + /// .to_string() + /// ); /// let mut dec = FixedDecimal::from_str("9.99").unwrap(); - /// assert_eq!("9.98", dec.trunced_to_increment(-2, RoundingIncrement::MultiplesOf2).to_string()); + /// assert_eq!( + /// "9.98", + /// dec.trunced_to_increment(-2, RoundingIncrement::MultiplesOf2) + /// .to_string() + /// ); /// ``` #[cfg(feature = "experimental")] pub fn trunced_to_increment(mut self, position: i16, increment: RoundingIncrement) -> Self { diff --git a/utils/litemap/src/databake.rs b/utils/litemap/src/databake.rs index dc33fcb3afe..d42085b9c6f 100644 --- a/utils/litemap/src/databake.rs +++ b/utils/litemap/src/databake.rs @@ -29,7 +29,8 @@ use databake::*; /// litemap_alloc.insert(10usize, "ten".to_string()); /// /// // Convert to a borrowed type for baking: -/// let litemap_str: LiteMap> = litemap_alloc.to_borrowed_values(); +/// let litemap_str: LiteMap> = +/// litemap_alloc.to_borrowed_values(); /// let litemap_slice: LiteMap = litemap_str.as_sliced(); /// /// // The bake will now work for const construction: diff --git a/utils/zerovec/src/map2d/map.rs b/utils/zerovec/src/map2d/map.rs index a50ef2c77c8..1975387a43f 100644 --- a/utils/zerovec/src/map2d/map.rs +++ b/utils/zerovec/src/map2d/map.rs @@ -303,18 +303,9 @@ where /// use zerovec::ZeroMap2d; /// /// let mut map = ZeroMap2d::new(); - /// assert_eq!( - /// map.insert(&0, "zero", "foo"), - /// None, - /// ); - /// assert_eq!( - /// map.insert(&1, "one", "bar"), - /// None, - /// ); - /// assert_eq!( - /// map.insert(&1, "one", "baz").as_deref(), - /// Some("bar"), - /// ); + /// assert_eq!(map.insert(&0, "zero", "foo"), None,); + /// assert_eq!(map.insert(&1, "one", "bar"), None,); + /// assert_eq!(map.insert(&1, "one", "baz").as_deref(), Some("bar"),); /// assert_eq!(map.get_2d(&1, "one").as_deref(), Some("baz")); /// assert_eq!(map.len(), 2); /// ```