Skip to content
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

Add EitherWriteable and use it for DoublePlaceholder in currency format #4750

Merged
merged 2 commits into from
Apr 2, 2024

Conversation

sffc
Copy link
Member

@sffc sffc commented Mar 27, 2024

Cleans up the currency formatter code a bit.

Part of #1441

@sffc sffc requested review from robertbastian, zbraniecki and a team as code owners March 27, 2024 23:57
@sffc sffc requested review from younies and removed request for a team and zbraniecki March 27, 2024 23:57
/// A [`Writeable`] that is either one type or another type.
#[derive(Debug, Clone, PartialEq, Eq)]
#[allow(clippy::exhaustive_enums)] // defined to be an enumeration over two types
pub enum EitherWriteable<W0, W1> {
Copy link
Member

Choose a reason for hiding this comment

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

either::Either is the standard Rust type to do this. Can we use that instead of defining our own?

Copy link
Member Author

@sffc sffc Mar 28, 2024

Choose a reason for hiding this comment

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

Fewer deps seems nice... we already have EitherYoke and EitherProvider defined in their respective crates. either isn't a "standard"; it's just a popular crate, like anyhow is a popular error handling crate but isn't a "standard".

@Manishearth opinion?

Copy link
Member

Choose a reason for hiding this comment

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

I'm okay with an optional dep here. I'm also somewhat open to moving EitherYoke to Either if possible.

a "standard"

"standard Rust type" does not necessarily mean it is "a standard", these have two different implications. I'd say either is the standard Rust type for this.

Copy link
Member

Choose a reason for hiding this comment

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

In general when it comes to deps we already pull in in a couple places I'm less worried about them. I still want our utils to be simple but it's fine if it's optional deps for crates that are extremely commonly found in Rust.

@sffc sffc added the discuss-priority Discuss at the next ICU4X meeting label Mar 28, 2024
@sffc
Copy link
Member Author

sffc commented Apr 2, 2024

Apparently icu_datetime already depends on either which makes me much less hesitant to add the impl that way

@sffc sffc requested a review from nordzilla as a code owner April 2, 2024 00:27
@sffc sffc requested review from Manishearth and removed request for nordzilla April 2, 2024 00:27
@Manishearth
Copy link
Member

Apparently icu_datetime already depends on either which makes me much less hesitant to add the impl that way

(yeah this is why I am also generally ok with introducing either in ICU4X for the larger deps)

@sffc sffc merged commit 63b8125 into unicode-org:main Apr 2, 2024
30 checks passed
@sffc sffc deleted the either-writeable branch April 2, 2024 01:18
@sffc
Copy link
Member Author

sffc commented Apr 2, 2024

@younies if you have any comments I can fix them in a follow-up. Turns out I need this PR for person names also, so I went ahead and merged it.

@sffc sffc removed the discuss-priority Discuss at the next ICU4X meeting label Apr 30, 2024
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