Skip to content

Conversation

@younies
Copy link
Member

@younies younies commented Jun 18, 2025

Description

  • Move power and si_prefix modules from the measure module to parser module.
  • Use the MeasureUnitParser without depending on an external data.
  • Remove the trie for unit indices.
  • Updated tests in area, length, mass, and volume categories to directly use MeasureUnitParser::try_from_str instead of creating a default parser instance.

NOTE
We need to add a future possibility for adding new units, but for now we can have a fixed place for unit names and ids.

younies added 2 commits June 18, 2025 14:35
# Description

- Removed unused `power` and `si_prefix` modules from the measure module.
- Updated tests in area, length, mass, and volume categories to directly use `MeasureUnitParser::try_from_str` instead of creating a default parser instance.
- Introduced new parser functionality for handling unit identifiers and SI prefixes, improving the overall structure and readability of the code.
@gemini-code-assist
Copy link

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

@younies younies marked this pull request as ready for review June 18, 2025 13:17
@younies younies requested review from a team, Manishearth, robertbastian and sffc as code owners June 18, 2025 13:18
Comment on lines 27 to 29
pub struct MeasureUnitParser;

impl MeasureUnitParser {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the type is no longer needed

Suggested change
pub struct MeasureUnitParser;
impl MeasureUnitParser {
impl MeasureUnit {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to have the MeasureUnitParser separate from MeasureUnit. Users will rarely need to use the parser, and in my opinion, separating it (along with the data) from MeasureUnit results in better organization.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it makes sense to have a parser type that doesn't have any state and is not constructible. We don't do this for any other types that have a try_from_str method.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by the way, it will be constructable in the future when will we allow the users to add their own units :)

@Manishearth Manishearth removed their request for review June 20, 2025 16:20
@younies younies requested a review from robertbastian June 20, 2025 16:50
Comment on lines 27 to 29
pub struct MeasureUnitParser;

impl MeasureUnitParser {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it makes sense to have a parser type that doesn't have any state and is not constructible. We don't do this for any other types that have a try_from_str method.

@younies younies closed this Jun 24, 2025
@younies younies reopened this Jun 24, 2025
@younies younies requested a review from robertbastian June 24, 2025 14:30
@younies younies requested a review from robertbastian July 3, 2025 12:51
Copy link
Member

@robertbastian robertbastian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are still open comments from my last reviews

Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a step in the right direction

@younies younies requested review from robertbastian and sffc July 8, 2025 14:00
robertbastian
robertbastian previously approved these changes Jul 8, 2025
@younies younies merged commit db7fe25 into unicode-org:main Jul 8, 2025
30 checks passed
@younies younies deleted the fix-ids branch July 8, 2025 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants