Skip to content

Commit

Permalink
Rename UnsignedFixedDecimal to UnsignedDecimal (#6143)
Browse files Browse the repository at this point in the history
# Description: 

Renames the UnsignedFixedDecimal type to UnsignedDecimal across multiple
files in the fixed_decimal module. This includes updates to:
- Rust source files
- Documentation
- Test files
- Dart bindings
- Diplomat coverage allowlist

The rename maintains the existing functionality while providing a more
concise type name.

Related Issues: #5065,
#6144


<!--
Thank you for your pull request to ICU4X!

Reminder: try to use [Conventional
Comments](https://conventionalcomments.org/) to make comments clearer.

Please see
https://github.com/unicode-org/icu4x/blob/main/CONTRIBUTING.md for
general
information on contributing to ICU4X.
-->
  • Loading branch information
younies authored Feb 18, 2025
1 parent d8d0e6b commit 4e260e1
Show file tree
Hide file tree
Showing 9 changed files with 378 additions and 468 deletions.
6 changes: 3 additions & 3 deletions components/experimental/src/duration/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use super::validated_options::Unit;
use core::fmt;
use core::fmt::Write;
use either::Either;
use fixed_decimal::{SignDisplay, SignedFixedDecimal, UnsignedFixedDecimal};
use fixed_decimal::{SignDisplay, SignedFixedDecimal, UnsignedDecimal};
use icu_decimal::FormattedDecimal;
use smallvec::SmallVec;
use writeable::{adapters::WithPart, PartsWrite, Writeable};
Expand Down Expand Up @@ -238,15 +238,15 @@ impl FormattedDuration<'_> {
] {
if style == FieldStyle::Fractional {
let val = val + prev_val / 1000;
prev_formatted.absolute = UnsignedFixedDecimal::from(val % 1000)
prev_formatted.absolute = UnsignedDecimal::from(val % 1000)
.concatenated_end(prev_formatted.absolute.multiplied_pow10(-3))
.unwrap();

prev_val = val;
} else {
return SignedFixedDecimal::new(
prev_formatted.sign,
UnsignedFixedDecimal::from(val)
UnsignedDecimal::from(val)
.concatenated_end(prev_formatted.absolute.multiplied_pow10(-3))
.unwrap(),
);
Expand Down
14 changes: 7 additions & 7 deletions ffi/capi/bindings/dart/SignedFixedDecimal.g.dart

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

22 changes: 8 additions & 14 deletions ffi/capi/src/fixed_decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,42 +191,36 @@ pub mod ffi {
)))
}

#[diplomat::rust_link(fixed_decimal::UnsignedFixedDecimal::digit_at, FnInStruct)]
#[diplomat::rust_link(fixed_decimal::UnsignedDecimal::digit_at, FnInStruct)]
pub fn digit_at(&self, magnitude: i16) -> u8 {
self.0.absolute.digit_at(magnitude)
}

#[diplomat::rust_link(fixed_decimal::UnsignedFixedDecimal::magnitude_range, FnInStruct)]
#[diplomat::rust_link(fixed_decimal::UnsignedDecimal::magnitude_range, FnInStruct)]
#[diplomat::attr(auto, getter)]
pub fn magnitude_start(&self) -> i16 {
*self.0.absolute.magnitude_range().start()
}

#[diplomat::rust_link(fixed_decimal::UnsignedFixedDecimal::magnitude_range, FnInStruct)]
#[diplomat::rust_link(fixed_decimal::UnsignedDecimal::magnitude_range, FnInStruct)]
#[diplomat::attr(auto, getter)]
pub fn magnitude_end(&self) -> i16 {
*self.0.absolute.magnitude_range().end()
}

#[diplomat::rust_link(
fixed_decimal::UnsignedFixedDecimal::nonzero_magnitude_start,
FnInStruct
)]
#[diplomat::rust_link(fixed_decimal::UnsignedDecimal::nonzero_magnitude_start, FnInStruct)]
#[diplomat::attr(auto, getter)]
pub fn nonzero_magnitude_start(&self) -> i16 {
self.0.absolute.nonzero_magnitude_start()
}

#[diplomat::rust_link(
fixed_decimal::UnsignedFixedDecimal::nonzero_magnitude_end,
FnInStruct
)]
#[diplomat::rust_link(fixed_decimal::UnsignedDecimal::nonzero_magnitude_end, FnInStruct)]
#[diplomat::attr(auto, getter)]
pub fn nonzero_magnitude_end(&self) -> i16 {
self.0.absolute.nonzero_magnitude_end()
}

#[diplomat::rust_link(fixed_decimal::UnsignedFixedDecimal::is_zero, FnInStruct)]
#[diplomat::rust_link(fixed_decimal::UnsignedDecimal::is_zero, FnInStruct)]
#[diplomat::attr(auto, getter)]
pub fn is_zero(&self) -> bool {
self.0.absolute.is_zero()
Expand Down Expand Up @@ -279,9 +273,9 @@ pub mod ffi {
self.0.absolute.trim_end()
}

#[diplomat::rust_link(fixed_decimal::UnsignedFixedDecimal::trim_end_if_integer, FnInStruct)]
#[diplomat::rust_link(fixed_decimal::UnsignedDecimal::trim_end_if_integer, FnInStruct)]
#[diplomat::rust_link(
fixed_decimal::UnsignedFixedDecimal::trimmed_end_if_integer,
fixed_decimal::UnsignedDecimal::trimmed_end_if_integer,
FnInStruct,
hidden
)]
Expand Down
2 changes: 1 addition & 1 deletion tools/make/diplomat-coverage/src/allowlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ lazy_static::lazy_static! {
// Not planned for 2.0
// We will revisit these APIs when Duration Formatter needs them. We may need to rename things
"fixed_decimal::Signed",
"fixed_decimal::UnsignedFixedDecimal",
"fixed_decimal::UnsignedDecimal",
"fixed_decimal::UnsignedRoundingMode",

// Not planned for 2.0
Expand Down
2 changes: 1 addition & 1 deletion utils/fixed_decimal/README.md

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

Loading

0 comments on commit 4e260e1

Please sign in to comment.