Skip to content

Commit

Permalink
Move icu_num_utils to utils/num (#303)
Browse files Browse the repository at this point in the history
* Move icu_num_utils to utils/num

* Add github action

* Rename to fixed-decimal

* Fix a spelling
  • Loading branch information
zbraniecki authored Oct 6, 2020
1 parent b100859 commit 06aecd5
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 30 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/perf-runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix
matrix:
component:
- locale
- num-util
- uniset
- components/locale
- components/uniset
- 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.
Expand All @@ -27,14 +27,14 @@ jobs:
- uses: actions/checkout@v2

- name: Run benchmark
run: cd components/${{ matrix.component }} && (cargo bench -- --output-format bencher | tee output.txt) && cd ../..
run: cd ./${{ matrix.component }} && (cargo bench -- --output-format bencher | tee output.txt) && cd ../..

- name: Store benchmark result (create dashboard)
uses: rhysd/github-action-benchmark@v1.8.1
with:
name: Rust Benchmark
tool: 'cargo'
output-file-path: components/${{ matrix.component }}/output.txt
output-file-path: ./${{ matrix.component }}/output.txt
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
fail-on-alert: true
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ members = [
"components/icu4x",
"components/uniset",
"components/locale",
"components/num-util",
"components/pluralrules",
"components/datetime",
"utils/fixed-decimal",
]
2 changes: 1 addition & 1 deletion components/pluralrules/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ include = [
[dependencies]
icu-locale = { path = "../locale" }
icu-data-provider = { path = "../data-provider" }
icu-num-util = { path = "../num-util" }
fixed-decimal = { path = "../../utils/fixed-decimal" }

[dev-dependencies]
criterion = "0.3"
Expand Down
2 changes: 1 addition & 1 deletion components/pluralrules/benches/operands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod fixtures;
mod helpers;

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use icu_num_util::FixedDecimal;
use fixed_decimal::FixedDecimal;
use icu_pluralrules::PluralOperands;
use std::convert::TryInto;

Expand Down
4 changes: 2 additions & 2 deletions components/pluralrules/src/operands.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use icu_num_util::FixedDecimal;
use fixed_decimal::FixedDecimal;
use std::convert::TryFrom;
use std::io::Error as IOError;
use std::isize;
Expand Down Expand Up @@ -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_num_util::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();
Expand Down
2 changes: 1 addition & 1 deletion components/pluralrules/tests/fixtures/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use icu_num_util::FixedDecimal;
use fixed_decimal::FixedDecimal;
use icu_pluralrules::PluralOperands;
use serde::Deserialize;
use std::convert::TryInto;
Expand Down
2 changes: 1 addition & 1 deletion components/pluralrules/tests/operands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod helpers;

use std::convert::TryInto;

use icu_num_util::FixedDecimal;
use fixed_decimal::FixedDecimal;
use icu_pluralrules::PluralOperands;

#[test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "icu-num-util"
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"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rand_pcg::Lcg64Xsh32;

use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};

use icu_num_util::FixedDecimal;
use fixed_decimal::FixedDecimal;
use std::str::FromStr;

fn triangular_nums(range: f64) -> Vec<isize> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_num_util::FixedDecimal;
use fixed_decimal::FixedDecimal;

fn main() {
let monetary_int = 19_9500;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const_assert!(std::mem::size_of::<usize>() >= std::mem::size_of::<u16>());
/// # Examples
///
/// ```
/// use icu_num_util::FixedDecimal;
/// use fixed_decimal::FixedDecimal;
///
/// let mut dec = FixedDecimal::from(250);
/// assert_eq!("250", dec.to_string());
Expand Down Expand Up @@ -70,7 +70,7 @@ pub struct FixedDecimal {
/// # Example
///
/// ```
/// use icu_num_util::FixedDecimal;
/// use fixed_decimal::FixedDecimal;
///
/// let mut dec: FixedDecimal = Default::default();
/// dec.is_negative = true;
Expand Down Expand Up @@ -190,7 +190,7 @@ impl FixedDecimal {
/// # Example
///
/// ```
/// use icu_num_util::FixedDecimal;
/// use fixed_decimal::FixedDecimal;
///
/// let dec = FixedDecimal::from(945);
/// assert_eq!(0, dec.digit_at(-1));
Expand Down Expand Up @@ -221,7 +221,7 @@ impl FixedDecimal {
/// # Example
///
/// ```
/// use icu_num_util::FixedDecimal;
/// use fixed_decimal::FixedDecimal;
///
/// let mut dec = FixedDecimal::from(120);
/// assert_eq!(0..=2, dec.magnitude_range());
Expand All @@ -241,7 +241,7 @@ impl FixedDecimal {
/// # Example
///
/// ```
/// use icu_num_util::FixedDecimal;
/// use fixed_decimal::FixedDecimal;
///
/// let mut dec = FixedDecimal::from(42);
/// assert_eq!("42", dec.to_string());
Expand Down Expand Up @@ -288,7 +288,7 @@ impl FixedDecimal {
/// # Example
///
/// ```
/// use icu_num_util::FixedDecimal;
/// use fixed_decimal::FixedDecimal;
///
/// let dec = FixedDecimal::from(42).multiplied_pow10(3).expect("Bounds are small");
/// assert_eq!("42000", dec.to_string());
Expand All @@ -305,7 +305,7 @@ impl FixedDecimal {
/// # Example
///
/// ```
/// use icu_num_util::FixedDecimal;
/// use fixed_decimal::FixedDecimal;
///
/// let dec = FixedDecimal::from(42);
/// let mut result = String::with_capacity(dec.write_len());
Expand All @@ -332,7 +332,7 @@ impl FixedDecimal {
/// # Example
///
/// ```
/// use icu_num_util::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());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `icu-num-util` is one of the [`ICU4X`] components.
//! `fixed-decimal` is a 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
Expand All @@ -7,7 +7,7 @@
//! # Example
//!
//! ```
//! use icu_num_util::FixedDecimal;
//! use fixed_decimal::FixedDecimal;
//!
//! let dec = FixedDecimal::from(250)
//! .multiplied_pow10(-2)
Expand Down Expand Up @@ -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 {
Expand All @@ -49,8 +49,8 @@ pub enum Error {
/// # Example
///
/// ```
/// use icu_num_util::FixedDecimal;
/// use icu_num_util::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());
Expand Down
File renamed without changes.

0 comments on commit 06aecd5

Please sign in to comment.