Skip to content

Commit

Permalink
Format docs (#4301)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian authored Nov 15, 2023
1 parent 666ef8a commit acd012c
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 30 deletions.
5 changes: 2 additions & 3 deletions components/plurals/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
///
Expand Down
19 changes: 10 additions & 9 deletions provider/core/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,7 @@ impl DataLocale {
/// .parse::<DataLocale>()
/// .unwrap()
/// .is_langid_und());
/// assert!("und-x-aux"
/// .parse::<DataLocale>()
/// .unwrap()
/// .is_langid_und());
/// assert!("und-x-aux".parse::<DataLocale>().unwrap().is_langid_und());
/// assert!(!"ca-ES".parse::<DataLocale>().unwrap().is_langid_und());
/// ```
pub fn is_langid_und(&self) -> bool {
Expand Down Expand Up @@ -871,16 +868,17 @@ 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();
/// let b = "abc".parse::<AuxiliaryKeys>().unwrap();
/// 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::<AuxiliaryKeys>().unwrap();
/// assert_eq!(a, b);
/// ```
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -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<_>>(), vec![subtag!("abc"), subtag!("defg")]);
/// assert_eq!(
/// aux.iter().collect::<Vec<_>>(),
/// vec![subtag!("abc"), subtag!("defg")]
/// );
/// ```
pub fn iter(&self) -> impl Iterator<Item = Subtag> + '_ {
self.value
Expand Down
30 changes: 25 additions & 5 deletions utils/fixed_decimal/src/decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion utils/litemap/src/databake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ use databake::*;
/// litemap_alloc.insert(10usize, "ten".to_string());
///
/// // Convert to a borrowed type for baking:
/// let litemap_str: LiteMap<usize, &str, Vec<_>> = litemap_alloc.to_borrowed_values();
/// let litemap_str: LiteMap<usize, &str, Vec<_>> =
/// litemap_alloc.to_borrowed_values();
/// let litemap_slice: LiteMap<usize, &str, &[_]> = litemap_str.as_sliced();
///
/// // The bake will now work for const construction:
Expand Down
15 changes: 3 additions & 12 deletions utils/zerovec/src/map2d/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
/// ```
Expand Down

0 comments on commit acd012c

Please sign in to comment.