Skip to content

[Feature] Add format_units_with #934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mattsse opened this issue Apr 21, 2025 · 1 comment · Fixed by #936
Closed

[Feature] Add format_units_with #934

mattsse opened this issue Apr 21, 2025 · 1 comment · Fixed by #936
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@mattsse
Copy link
Member

mattsse commented Apr 21, 2025

Component

primitives

Describe the feature you would like

we format units like:

/// Formats the given number of Wei as the given unit.
///
/// See [`format_units`] for more information.
pub fn format_units(&self, mut unit: Unit) -> String {

only supporting .:

format!("{integer}.{decimals:0>units$}")

it would be nice if we can support locale settings, but we only need "." and "," here really.

we can make this work with a helper enum, like enum DecimalSeparator {Command, Period}

TODO

  • introduce a new fn that accepts this helper type
  • refactor existing fn so that this simply calls format_units_with(..., DecimalSeparator::Period)

maybe @Rimeeeeee

Additional context

No response

@mattsse mattsse added the enhancement New feature or request label Apr 21, 2025
@github-project-automation github-project-automation bot moved this to Todo in Alloy Apr 21, 2025
@mattsse mattsse added the good first issue Good for newcomers label Apr 21, 2025
@Rimeeeeee
Copy link
Contributor

Will look into this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants