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 GC predicate functions #1310

Merged
merged 5 commits into from
Dec 1, 2021
Merged

Conversation

echeran
Copy link
Contributor

@echeran echeran commented Nov 17, 2021

Fixes #1158

@echeran echeran requested a review from sffc November 17, 2021 22:33
Comment on lines 248 to 251
pub fn is_cased_letter(gc_map: &CodePointTrie<GeneralSubcategory>, code_point: u32) -> bool {
let gc_val = gc_map.get(code_point);
0 != (gc_val as u32) & GeneralCategory::CasedLetter.0
}
Copy link
Member

Choose a reason for hiding this comment

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

Two other ways:

impl GeneralSubcategory {
    pub fn is_contained(gc: GeneralCategory) -> bool {
        // do the test
    }
}
impl GeneralCategory {
    pub fn contains(gsc: GeneralSubcategory) -> bool {
        // opposite of above
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done before a previous review. Took the second approach.

/// ```
pub fn is_letter(gc_map: &CodePointTrie<GeneralSubcategory>, code_point: u32) -> bool {
let gc_val = gc_map.get(code_point);
0 != (gc_val as u32) & GeneralCategory::Letter.0
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
0 != (gc_val as u32) & GeneralCategory::Letter.0
0 != (1 << (gc_val as u32)) & GeneralCategory::Letter.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done before a previous review.

@echeran echeran linked an issue Nov 17, 2021 that may be closed by this pull request
@echeran echeran marked this pull request as ready for review November 18, 2021 00:35
@echeran echeran requested a review from a team as a code owner November 18, 2021 00:35
@echeran echeran requested a review from sffc November 18, 2021 00:35
sffc
sffc previously approved these changes Nov 22, 2021
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 with a suggestion for better documentation

components/properties/src/props.rs Outdated Show resolved Hide resolved
Co-authored-by: Shane F. Carr <shane@unicode.org>
@echeran echeran requested a review from sffc December 1, 2021 00:01
@echeran echeran merged commit 910cf45 into unicode-org:main Dec 1, 2021
@echeran echeran deleted the props-gc-pred-fns branch December 1, 2021 17:11
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.

Predicate functions for General_Category
2 participants