Skip to content

Various changes #4

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

Merged
merged 3 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions scripts/unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
# except according to those terms.

# This script uses the following Unicode tables:
# - DerivedCoreProperties.txt
# - auxiliary/GraphemeBreakProperty.txt
# - auxiliary/WordBreakProperty.txt
# - ReadMe.txt
# - UnicodeData.txt
# - PropertyValueAliases.txt
# - ScriptExtensions.txt
# - Scripts.txt
#
# Since this should not require frequent updates, we just store this
# out-of-line and check the unicode.rs file into git.
Expand All @@ -39,7 +37,7 @@
use super::ScriptExtension;
'''

UNICODE_VERSION = (12, 0, 0)
UNICODE_VERSION = (13, 0, 0)

UNICODE_VERSION_NUMBER = "%s.%s.%s" %UNICODE_VERSION

Expand Down
13 changes: 11 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ impl ScriptExtension {
(self.first == 0) & (self.second == 0) & (self.third == 0)
}

/// Returns the number of scripts in the script extension
pub fn len(self) -> usize {
if self.is_common_or_inherited() {
1
} else {
(self.first.count_ones() + self.second.count_ones() + self.third.count_ones()) as usize
}
}

/// Intersect this `ScriptExtension` with another `ScriptExtension`. Produces `Unknown` if things
/// do not intersect. This is equivalent to [`ScriptExtension::intersection`] but it stores the result
/// in `self`
Expand Down Expand Up @@ -257,9 +266,9 @@ impl ScriptExtension {
ext
}

/// Iterate over the scripts in this string
/// Iterate over the scripts in this script extension
///
/// Will never yeild Script::Unknown
/// Will never yield Script::Unknown
pub fn iter(self) -> ScriptIterator {
ScriptIterator { ext: self }
}
Expand Down
Loading