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

Move CodePointTrie to components/utils #1114

Merged
merged 18 commits into from
Oct 1, 2021
Merged

Conversation

echeran
Copy link
Contributor

@echeran echeran commented Sep 27, 2021

Closes #1070

Done so far in this PR:

  • Write Serde impl
  • Remove second type param
  • Audit documentation

@echeran echeran linked an issue Sep 28, 2021 that may be closed by this pull request
2 tasks
utils/codepointtrie/src/codepointtrie.rs Show resolved Hide resolved
pub struct CodePointTrie<'trie, W: ValueWidth, T: TrieType> {
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct CodePointTrie<'trie, W: ValueWidth>
where <<W as AsULE>::ULE as ULE>::Error: Display
Copy link
Contributor Author

Choose a reason for hiding this comment

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

One of the compiler errors was that, as I understood it, the default implementation of Serde provided by the derive required that the Error type implement std::fmt::Display, but instead, the added trait bound uses core::fmt::Display. Is that ok?

Copy link
Member

Choose a reason for hiding this comment

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

We should avoid putting trait bounds on the struct. Trait bounds belong on impls. Serde complaining isn't a good reason to put a trait bound on a struct. Manish shared a really good article on the subject last week: https://stackoverflow.com/questions/49229332/should-trait-bounds-be-duplicated-in-struct-and-impl/66369912#66369912

@echeran echeran marked this pull request as ready for review October 1, 2021 01:03
@echeran echeran requested a review from a team as a code owner October 1, 2021 01:03
@echeran echeran requested a review from sffc October 1, 2021 01:03
utils/codepointtrie/src/codepointtrie.rs Show resolved Hide resolved
utils/codepointtrie/src/codepointtrie.rs Outdated Show resolved Hide resolved
utils/codepointtrie/tests/planes_test.rs Outdated Show resolved Hide resolved
utils/codepointtrie/src/codepointtrie.rs Outdated Show resolved Hide resolved
utils/codepointtrie/Cargo.toml Outdated Show resolved Hide resolved
@echeran echeran requested a review from sffc October 1, 2021 01:58
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.

LGTM

@sffc sffc requested a review from Manishearth October 1, 2021 02:04
@sffc
Copy link
Member

sffc commented Oct 1, 2021

CC @Manishearth who may want to review this

Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

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

Seems good to me! Losing the TrieType enum looks much nicer

@sffc sffc mentioned this pull request Oct 1, 2021
3 tasks
@echeran echeran merged commit d11c840 into unicode-org:main Oct 1, 2021
@echeran echeran deleted the cpt-utils branch October 1, 2021 14:33
robertbastian pushed a commit to robertbastian/icu4x that referenced this pull request Oct 4, 2021
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.

CodePointTrie - polish and move to utils Improve codepointtrie crate for components
3 participants