Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e8a8e16

Browse files
committed
Upgrade to unicode-script 0.5.1
1 parent 7c89ffb commit e8a8e16

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ according to Unicode Technical Standard #39 rules.
1616
exclude = [ "target/*", "Cargo.lock" ]
1717

1818
[dependencies]
19-
unicode-script = { version = "0.4.0", default-features = false }
19+
unicode-script = { version = "0.5.1", default-features = false }
2020
unicode-normalization = { version = "0.1.12", default-features = false }
2121
std = { version = "1.0", package = "rustc-std-workspace-std", optional = true }
2222
core = { version = "1.0", package = "rustc-std-workspace-core", optional = true }

src/mixed_script.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ impl From<ScriptExtension> for AugmentedScriptSet {
2323
let mut jpan = false;
2424
let mut kore = false;
2525

26-
if ext == ScriptExtension::Single(Script::Common)
27-
|| ext == ScriptExtension::Single(Script::Inherited)
28-
|| ext.contains_script(Script::Han)
29-
{
26+
if ext.is_common() || ext.is_inherited() || ext.contains_script(Script::Han) {
3027
hanb = true;
3128
jpan = true;
3229
kore = true;
@@ -67,7 +64,7 @@ impl From<&'_ str> for AugmentedScriptSet {
6764
impl Default for AugmentedScriptSet {
6865
fn default() -> Self {
6966
AugmentedScriptSet {
70-
base: ScriptExtension::Single(Script::Common),
67+
base: Script::Common.into(),
7168
hanb: true,
7269
jpan: true,
7370
kore: true,
@@ -91,8 +88,7 @@ impl AugmentedScriptSet {
9188

9289
/// Check if the set is "All" (Common or Inherited)
9390
pub fn is_all(&self) -> bool {
94-
self.base == ScriptExtension::Single(Script::Common)
95-
|| self.base == ScriptExtension::Single(Script::Inherited)
91+
self.base.is_common() || self.base.is_inherited()
9692
}
9793

9894
/// Construct an AugmentedScriptSet for a given character

src/restriction_level.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
use crate::mixed_script::AugmentedScriptSet;
55
use crate::GeneralSecurityProfile;
6-
use unicode_script::{Script, ScriptExtension};
6+
use unicode_script::Script;
77

88
#[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
99
/// The [Restriction level](https://www.unicode.org/reports/tr39/#Restriction_Level_Detection)
@@ -64,7 +64,8 @@ impl RestrictionLevelDetection for &'_ str {
6464
return RestrictionLevel::SingleScript;
6565
} else if exclude_latin_set.kore || exclude_latin_set.hanb || exclude_latin_set.jpan {
6666
return RestrictionLevel::HighlyRestrictive;
67-
} else if let ScriptExtension::Single(script) = exclude_latin_set.base {
67+
} else if exclude_latin_set.base.len() == 1 {
68+
let script = exclude_latin_set.base.iter().next().unwrap();
6869
if script.is_recommended() && script != Script::Cyrillic && script != Script::Greek {
6970
return RestrictionLevel::ModeratelyRestrictive;
7071
}

0 commit comments

Comments
 (0)