diff --git a/.github/workflows/perf-runtime.yml b/.github/workflows/perf-runtime.yml index 7ff00db5560..1f80f72b167 100644 --- a/.github/workflows/perf-runtime.yml +++ b/.github/workflows/perf-runtime.yml @@ -16,7 +16,7 @@ jobs: component: - components/locale - components/uniset - - utils/num + - utils/fixed-decimal # If you are modifying and debugging is required, don't be afraid to get # messy in a personal fork, if no better way to do it. diff --git a/Cargo.toml b/Cargo.toml index 7b4e47f2275..abf3116d251 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,5 +10,5 @@ members = [ "components/locale", "components/pluralrules", "components/datetime", - "utils/num", + "utils/fixed-decimal", ] diff --git a/components/pluralrules/Cargo.toml b/components/pluralrules/Cargo.toml index 3ebb396f328..54d9479a613 100644 --- a/components/pluralrules/Cargo.toml +++ b/components/pluralrules/Cargo.toml @@ -17,7 +17,7 @@ include = [ [dependencies] icu-locale = { path = "../locale" } icu-data-provider = { path = "../data-provider" } -icu-utils-num = { path = "../../utils/num" } +fixed-decimal = { path = "../../utils/fixed-decimal" } [dev-dependencies] criterion = "0.3" diff --git a/components/pluralrules/benches/operands.rs b/components/pluralrules/benches/operands.rs index cc1b4dce91d..3d603db4580 100644 --- a/components/pluralrules/benches/operands.rs +++ b/components/pluralrules/benches/operands.rs @@ -2,7 +2,7 @@ mod fixtures; mod helpers; use criterion::{black_box, criterion_group, criterion_main, Criterion}; -use icu_utils_num::FixedDecimal; +use fixed_decimal::FixedDecimal; use icu_pluralrules::PluralOperands; use std::convert::TryInto; diff --git a/components/pluralrules/src/operands.rs b/components/pluralrules/src/operands.rs index 712d76f2544..00dbfee8ca7 100644 --- a/components/pluralrules/src/operands.rs +++ b/components/pluralrules/src/operands.rs @@ -1,4 +1,4 @@ -use icu_utils_num::FixedDecimal; +use fixed_decimal::FixedDecimal; use std::convert::TryFrom; use std::io::Error as IOError; use std::isize; @@ -201,7 +201,7 @@ impl_integer_type!(u8 u16 u32 u64 u128 usize); impl_signed_integer_type!(i8 i16 i32 i64 i128 isize); impl From<&FixedDecimal> for PluralOperands { - /// Converts a [icu_utils_num::FixedDecimal] to [PluralOperands]. Retains at most 18 + /// Converts a [fixed_decimal::FixedDecimal] to [PluralOperands]. Retains at most 18 /// digits each from the integer and fraction parts. fn from(dec: &FixedDecimal) -> Self { let mag_range = dec.magnitude_range(); diff --git a/components/pluralrules/tests/fixtures/mod.rs b/components/pluralrules/tests/fixtures/mod.rs index 3ef049f8f36..d419f94a70a 100644 --- a/components/pluralrules/tests/fixtures/mod.rs +++ b/components/pluralrules/tests/fixtures/mod.rs @@ -1,4 +1,4 @@ -use icu_utils_num::FixedDecimal; +use fixed_decimal::FixedDecimal; use icu_pluralrules::PluralOperands; use serde::Deserialize; use std::convert::TryInto; diff --git a/components/pluralrules/tests/operands.rs b/components/pluralrules/tests/operands.rs index 238f8323794..850ce91f2b3 100644 --- a/components/pluralrules/tests/operands.rs +++ b/components/pluralrules/tests/operands.rs @@ -3,7 +3,7 @@ mod helpers; use std::convert::TryInto; -use icu_utils_num::FixedDecimal; +use fixed_decimal::FixedDecimal; use icu_pluralrules::PluralOperands; #[test] diff --git a/utils/num/Cargo.toml b/utils/fixed-decimal/Cargo.toml similarity index 84% rename from utils/num/Cargo.toml rename to utils/fixed-decimal/Cargo.toml index da8298c1536..f3fb9901570 100644 --- a/utils/num/Cargo.toml +++ b/utils/fixed-decimal/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "icu-utils-num" -description = "Low-level tools for dealing with numbers" +name = "fixed-decimal" +description = "An API for representing numbers in a human-readable form" version = "0.0.1" authors = ["The ICU4X Project Developers"] edition = "2018" diff --git a/utils/num/README.md b/utils/fixed-decimal/README.md similarity index 100% rename from utils/num/README.md rename to utils/fixed-decimal/README.md diff --git a/utils/num/benches/fixed_decimal.rs b/utils/fixed-decimal/benches/fixed_decimal.rs similarity index 99% rename from utils/num/benches/fixed_decimal.rs rename to utils/fixed-decimal/benches/fixed_decimal.rs index cfc4c53d8bb..daaa7a6a5a6 100644 --- a/utils/num/benches/fixed_decimal.rs +++ b/utils/fixed-decimal/benches/fixed_decimal.rs @@ -4,7 +4,7 @@ use rand_pcg::Lcg64Xsh32; use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion}; -use icu_utils_num::FixedDecimal; +use fixed_decimal::FixedDecimal; use std::str::FromStr; fn triangular_nums(range: f64) -> Vec { diff --git a/utils/num/examples/permyriad.rs b/utils/fixed-decimal/examples/permyriad.rs similarity index 93% rename from utils/num/examples/permyriad.rs rename to utils/fixed-decimal/examples/permyriad.rs index 82fba0aebfc..49896d30db7 100644 --- a/utils/num/examples/permyriad.rs +++ b/utils/fixed-decimal/examples/permyriad.rs @@ -2,7 +2,7 @@ // (one permyriad) of a monetary unit. FixedDecimal enables a cheap representation of these // amounts, also while retaining trailing zeros. -use icu_utils_num::FixedDecimal; +use fixed_decimal::FixedDecimal; fn main() { let monetary_int = 19_9500; diff --git a/utils/num/src/fixed_decimal.rs b/utils/fixed-decimal/src/decimal.rs similarity index 98% rename from utils/num/src/fixed_decimal.rs rename to utils/fixed-decimal/src/decimal.rs index 8283535d466..4121f500658 100644 --- a/utils/num/src/fixed_decimal.rs +++ b/utils/fixed-decimal/src/decimal.rs @@ -26,7 +26,7 @@ const_assert!(std::mem::size_of::() >= std::mem::size_of::()); /// # Examples /// /// ``` -/// use icu_utils_num::FixedDecimal; +/// use fixed_decimal::FixedDecimal; /// /// let mut dec = FixedDecimal::from(250); /// assert_eq!("250", dec.to_string()); @@ -70,7 +70,7 @@ pub struct FixedDecimal { /// # Example /// /// ``` - /// use icu_utils_num::FixedDecimal; + /// use fixed_decimal::FixedDecimal; /// /// let mut dec: FixedDecimal = Default::default(); /// dec.is_negative = true; @@ -190,7 +190,7 @@ impl FixedDecimal { /// # Example /// /// ``` - /// use icu_utils_num::FixedDecimal; + /// use fixed_decimal::FixedDecimal; /// /// let dec = FixedDecimal::from(945); /// assert_eq!(0, dec.digit_at(-1)); @@ -221,7 +221,7 @@ impl FixedDecimal { /// # Example /// /// ``` - /// use icu_utils_num::FixedDecimal; + /// use fixed_decimal::FixedDecimal; /// /// let mut dec = FixedDecimal::from(120); /// assert_eq!(0..=2, dec.magnitude_range()); @@ -241,7 +241,7 @@ impl FixedDecimal { /// # Example /// /// ``` - /// use icu_utils_num::FixedDecimal; + /// use fixed_decimal::FixedDecimal; /// /// let mut dec = FixedDecimal::from(42); /// assert_eq!("42", dec.to_string()); @@ -288,7 +288,7 @@ impl FixedDecimal { /// # Example /// /// ``` - /// use icu_utils_num::FixedDecimal; + /// use fixed_decimal::FixedDecimal; /// /// let dec = FixedDecimal::from(42).multiplied_pow10(3).expect("Bounds are small"); /// assert_eq!("42000", dec.to_string()); @@ -305,7 +305,7 @@ impl FixedDecimal { /// # Example /// /// ``` - /// use icu_utils_num::FixedDecimal; + /// use fixed_decimal::FixedDecimal; /// /// let dec = FixedDecimal::from(42); /// let mut result = String::with_capacity(dec.write_len()); @@ -332,7 +332,7 @@ impl FixedDecimal { /// # Example /// /// ``` - /// use icu_utils_num::FixedDecimal; + /// use fixed_decimal::FixedDecimal; /// /// let dec = FixedDecimal::from(-5000).multiplied_pow10(-2).expect("Bounds are small"); /// let mut result = String::with_capacity(dec.write_len()); diff --git a/utils/num/src/lib.rs b/utils/fixed-decimal/src/lib.rs similarity index 89% rename from utils/num/src/lib.rs rename to utils/fixed-decimal/src/lib.rs index 288d9b9eec9..3ed11a5d29d 100644 --- a/utils/num/src/lib.rs +++ b/utils/fixed-decimal/src/lib.rs @@ -1,4 +1,4 @@ -//! `icu-num-util` is one of the [`ICU4X`] components. +//! `fixed-decimal` is an utility crate of the [`ICU4X`] project. //! //! It includes [`FixedDecimal`], a core API for representing numbers in a human-readable form //! appropriate for formatting and plural rule selection. It is optimized for operations involving @@ -7,7 +7,7 @@ //! # Example //! //! ``` -//! use icu_utils_num::FixedDecimal; +//! use fixed_decimal::FixedDecimal; //! //! let dec = FixedDecimal::from(250) //! .multiplied_pow10(-2) @@ -35,10 +35,10 @@ //! [`FixedDecimal`]: ./struct.FixedDecimal.html //! [`ICU4X`]: https://github.com/unicode-org/icu4x -pub mod fixed_decimal; +pub mod decimal; mod uint_iterator; -pub use fixed_decimal::FixedDecimal; +pub use decimal::FixedDecimal; #[derive(Debug, PartialEq)] pub enum Error { @@ -49,8 +49,8 @@ pub enum Error { /// # Example /// /// ``` - /// use icu_utils_num::FixedDecimal; - /// use icu_utils_num::Error; + /// use fixed_decimal::FixedDecimal; + /// use fixed_decimal::Error; /// /// let mut dec1 = FixedDecimal::from(123); /// assert_eq!(Error::Limit, dec1.multiply_pow10(std::i16::MAX).unwrap_err()); diff --git a/utils/num/src/uint_iterator.rs b/utils/fixed-decimal/src/uint_iterator.rs similarity index 100% rename from utils/num/src/uint_iterator.rs rename to utils/fixed-decimal/src/uint_iterator.rs