8000 Add intersection()/intersect_with() · unicode-rs/unicode-script@f156781 · GitHub
[go: up one dir, main page]

Skip to content

Commit f156781

Browse files
committed
Add intersection()/intersect_with()
1 parent 6c286e4 commit f156781

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,20 @@ impl ScriptExtension {
4545
///
4646
/// "Common" (`Zyyy`) and "Inherited" (`Zinh`) are considered as intersecting
4747
/// everything.
48-
pub fn intersect(self, other: Self) -> Self {
48+
pub fn intersection(&mut self, other: Self) -> Self {
4949
self.inner_intersect(other)
5050
}
5151

52+
/// Intersect this ScriptExtension with another ScriptExtension. Produces Unknown if things
53+
/// do not intersect. This is equivalent to [`ScriptExtension::intersection`] but it stores the result
54+
/// in `self`
55+
///
56+
/// "Common" (`Zyyy`) and "Inherited" (`Zinh`) are considered as intersecting
57+
/// everything.
58+
pub fn intersect_with(&mut self, other: Self) {
59+
*self = self.inner_intersect(other)
60+
}
61+
5262
/// Checks if the script extension is empty (unknown)
5363
pub fn is_empty(self) -> bool {
5464
self == ScriptExtension::Single(Script::Unknown)

0 commit comments

Comments
 (0)
0