8000 Add a `ScriptExtension::len` method · popzxc/unicode-script@716c18e · GitHub
[go: up one dir, main page]

Skip to content

Commit 716c18e

Browse files
committed
Add a ScriptExtension::len method
1 parent 4a8cb11 commit 716c18e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,15 @@ impl ScriptExtension {
193193
(self.first == 0) & (self.second == 0) & (self.third == 0)
194194
}
195195

196+
/// Returns the number of scripts in the script extension
197+
pub fn len(self) -> usize {
198+
if self.is_common_or_inherited() {
199+
1
200+
} else {
201+
(self.first.count_ones() + self.second.count_ones() + self.third.count_ones()) as usize
202+
}
203+
}
204+
196205
/// Intersect this `ScriptExtension` with another `ScriptExtension`. Produces `Unknown` if things
197206
/// do not intersect. This is equivalent to [`ScriptExtension::intersection`] but it stores the result
198207
/// in `self`

0 commit comments

Comments
 (0)
0