Skip to content

Commit

Permalink
Rename fdf to formatter in decimal formatting examples and benchm…
Browse files Browse the repository at this point in the history
…arks (#6150)
  • Loading branch information
younies authored Feb 18, 2025
1 parent 83072d1 commit 5aa8c99
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 32 deletions.
18 changes: 9 additions & 9 deletions components/decimal/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions components/decimal/benches/fixed_decimal_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ fn overview_bench(c: &mut Criterion) {
b.iter(|| {
// This benchmark demonstrates the performance of the format function on 1000 numbers
// ranging from -1e9 to 1e9.
let fdf = DecimalFormatter::try_new(prefs, options).unwrap();
let formatter = DecimalFormatter::try_new(prefs, options).unwrap();
for &num in &nums {
let fd = Decimal::from(black_box(num));
fdf.format_to_string(&fd);
let decimal = Decimal::from(black_box(num));
formatter.format_to_string(&decimal);
}
});
});
Expand Down
4 changes: 2 additions & 2 deletions components/decimal/src/grouper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ fn test_grouper() {
grouping_strategy: Some(cas.strategy),
..Default::default()
};
let fdf =
let formatter =
DecimalFormatter::try_new_unstable(&provider, Default::default(), options).unwrap();
let actual = fdf.format(&dec);
let actual = formatter.format(&dec);
assert_writeable_eq!(actual, cas.expected[i], "{:?}", cas);
}
}
Expand Down
18 changes: 9 additions & 9 deletions components/decimal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
//! use icu::locale::locale;
//! use writeable::assert_writeable_eq;
//!
//! let df = DecimalFormatter::try_new(
//! let formatter = DecimalFormatter::try_new(
//! locale!("bn").into(),
//! Default::default(),
//! )
//! .expect("locale should be present");
//!
//! let fixed_decimal = Decimal::from(1000007);
//! let decimal = Decimal::from(1000007);
//!
//! assert_writeable_eq!(df.format(&fixed_decimal), "১০,০০,০০৭");
//! assert_writeable_eq!(formatter.format(&decimal), "১০,০০,০০৭");
//! ```
//!
//! ## Format a number with digits after the decimal separator
Expand All @@ -39,17 +39,17 @@
//! use icu::locale::Locale;
//! use writeable::assert_writeable_eq;
//!
//! let df =
//! let formatter =
//! DecimalFormatter::try_new(Default::default(), Default::default())
//! .expect("locale should be present");
//!
//! let fixed_decimal = {
//! let decimal = {
//! let mut decimal = Decimal::from(200050);
//! decimal.multiply_pow10(-2);
//! decimal
//! };
//!
//! assert_writeable_eq!(df.format(&fixed_decimal), "2,000.50");
//! assert_writeable_eq!(formatter.format(&decimal), "2,000.50");
//! ```
//!
//! ## Format a number using an alternative numbering system
Expand All @@ -62,15 +62,15 @@
//! use icu::locale::locale;
//! use writeable::assert_writeable_eq;
//!
//! let fdf = DecimalFormatter::try_new(
//! let formatter = DecimalFormatter::try_new(
//! locale!("th-u-nu-thai").into(),
//! Default::default(),
//! )
//! .expect("locale should be present");
//!
//! let fixed_decimal = Decimal::from(1000007);
//! let decimal = Decimal::from(1000007);
//!
//! assert_writeable_eq!(fdf.format(&fixed_decimal), "๑,๐๐๐,๐๐๗");
//! assert_writeable_eq!(formatter.format(&decimal), "๑,๐๐๐,๐๐๗");
//! ```
//!
//! [`DecimalFormatter`]: DecimalFormatter
Expand Down
6 changes: 3 additions & 3 deletions components/decimal/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ impl From<GroupingStrategy> for DecimalFormatterOptions {
/// let locale = Default::default();
/// let mut options: options::DecimalFormatterOptions = Default::default();
/// options.grouping_strategy = Some(options::GroupingStrategy::Min2);
/// let df = DecimalFormatter::try_new(locale, options)
/// let formatter = DecimalFormatter::try_new(locale, options)
/// .expect("locale should be present");
///
/// let one_thousand = 1000.into();
/// assert_writeable_eq!(df.format(&one_thousand), "1000");
/// assert_writeable_eq!(formatter.format(&one_thousand), "1000");
///
/// let ten_thousand = 10000.into();
/// assert_writeable_eq!(df.format(&ten_thousand), "10,000");
/// assert_writeable_eq!(formatter.format(&ten_thousand), "10,000");
/// ```
#[non_exhaustive]
#[derive(Debug, Eq, PartialEq, Clone, Copy, Hash, Default)]
Expand Down
6 changes: 3 additions & 3 deletions components/decimal/src/parts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
//! use icu::locale::locale;
//! use writeable::assert_writeable_parts_eq;
//!
//! let df = DecimalFormatter::try_new(
//! let formatter = DecimalFormatter::try_new(
//! locale!("en").into(),
//! Default::default(),
//! )
//! .unwrap();
//!
//! let fixed_decimal = "-987654.321".parse().unwrap();
//! let decimal = "-987654.321".parse().unwrap();
//!
//! // Missing data is filled in on a best-effort basis, and an error is signaled.
//! assert_writeable_parts_eq!(
//! df.format(&fixed_decimal),
//! formatter.format(&decimal),
//! "-987,654.321",
//! [
//! (0, 1, parts::MINUS_SIGN),
Expand Down
6 changes: 3 additions & 3 deletions components/decimal/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
//! numbering_system: RefCell::new(None),
//! };
//!
//! let df = DecimalFormatter::try_new_unstable(
//! let formatter = DecimalFormatter::try_new_unstable(
//! &provider,
//! locale!("th").into(),
//! Default::default(),
Expand All @@ -59,7 +59,7 @@
//!
//! assert_eq!(provider.numbering_system.borrow().as_ref().map(|x| x.as_str()), Some("latn"));
//!
//! let df = DecimalFormatter::try_new_unstable(
//! let formatter = DecimalFormatter::try_new_unstable(
//! &provider,
//! locale!("th-u-nu-thai").into(),
//! Default::default(),
Expand All @@ -68,7 +68,7 @@
//!
//! assert_eq!(provider.numbering_system.borrow().as_ref().map(|x| x.as_str()), Some("thai"));
//!
//! let df = DecimalFormatter::try_new_unstable(
//! let formatter = DecimalFormatter::try_new_unstable(
//! &provider,
//! locale!("th-u-nu-adlm").into(),
//! Default::default(),
Expand Down

0 comments on commit 5aa8c99

Please sign in to comment.