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

Make ULE types Copy, add PairULE #1193

Merged
merged 7 commits into from
Oct 20, 2021
Merged

Conversation

Manishearth
Copy link
Member

Fixes #1184

I was adding PairULE and was hitting rust-lang/rust#82523 (comment) . I decided to use this opportunity to make things Copy anyway.

I much prefer the new API, there's no need to take superfluous & references to satisfy the compiler.

@Manishearth
Copy link
Member Author

This does minor refactorings of a lot of code, which is why it tagged everyone in as an owner.

I think after this I'm going to cut a version of ZeroVec so that tinystr can be brought up to date, we've had a lot of changes and I'd like them to be published. I still have stuff to do but this is a reasonable milestone since almost all of the other stuff is additive.

/// We do not have guarantees for the layouts of tuples, so we must define a custom
/// ULE type for pairs. This could potentially be generalized for larger tuples if necessary
#[repr(packed)]
pub struct PairULE<A, B>(pub A, pub B);
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: can we make a 3-part and 4-part ULE as well? I think we may need at least 3 for the LocaleCanonicalizer stuff (language script region).

Copy link
Member Author

Choose a reason for hiding this comment

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

My understanding was that those were maps from language to script/region? We can add the 3-part one when needed imo, it should be easy to copy PairULE

utils/zerovec/src/ule/pair.rs Show resolved Hide resolved
IncorrectLength(/* expected */ usize, /* found */ usize),
}

impl<E: fmt::Display, F: fmt::Display> fmt::Display for PairULEError<E, F> {
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion (optional): it would be nicer to use displaydoc but I know you don't want to add that dep

Copy link
Member Author

Choose a reason for hiding this comment

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

We can't use derives on this type

utils/zerovec/src/ule/pair.rs Outdated Show resolved Hide resolved
utils/zerovec/src/zerovec/mod.rs Show resolved Hide resolved
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.

This is good for now, and we can add 3-part or 4-part ULEs later when needed

@Manishearth Manishearth merged commit 81aaa42 into unicode-org:main Oct 20, 2021
@Manishearth Manishearth deleted the pair-ule branch October 20, 2021 19:57
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.

Consider requiring all ULEs to be Copy
2 participants