From: Ben Pfaff Date: Fri, 18 Jul 2025 00:14:08 +0000 (-0700) Subject: rust: Switch from `finl_unicode` to `unicode-properties` crate. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=774e1086773ba8f8935f0f9fb9aaf13347c8aec6;p=pspp rust: Switch from `finl_unicode` to `unicode-properties` crate. I like its design better. --- diff --git a/rust/pspp/Cargo.toml b/rust/pspp/Cargo.toml index 73a2188660..3ad04a1296 100644 --- a/rust/pspp/Cargo.toml +++ b/rust/pspp/Cargo.toml @@ -16,7 +16,6 @@ num = "0.4.0" ordered-float = "3.7.0" thiserror = "1.0" chrono = "0.4.40" -finl_unicode = "1.2.0" unicase = "2.6.0" libc = "0.2.147" indexmap = "2.1.0" @@ -49,6 +48,7 @@ cmac = "0.7.2" aes = "0.8.4" readpass = "1.0.3" zeroize = "1.8.1" +unicode-properties = "0.1.3" [target.'cfg(windows)'.dependencies] windows-sys = { version = "0.48.0", features = ["Win32_Globalization"] } diff --git a/rust/pspp/src/identifier.rs b/rust/pspp/src/identifier.rs index cc9b1f213e..823ba6e971 100644 --- a/rust/pspp/src/identifier.rs +++ b/rust/pspp/src/identifier.rs @@ -23,9 +23,9 @@ use std::{ }; use encoding_rs::{EncoderResult, Encoding, UTF_8}; -use finl_unicode::categories::{CharacterCategories, MajorCategory}; use thiserror::Error as ThisError; use unicase::UniCase; +use unicode_properties::UnicodeGeneralCategory; #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum Class { @@ -88,9 +88,10 @@ impl IdentifierChar for char { if self < '\u{0080}' { self.ascii_may_start_id() } else { - use MajorCategory::*; + use unicode_properties::GeneralCategoryGroup::*; - [L, M, S].contains(&self.get_major_category()) && self != char::REPLACEMENT_CHARACTER + matches!(self.general_category_group(), Letter | Mark | Symbol) + && self != char::REPLACEMENT_CHARACTER } } @@ -102,9 +103,12 @@ impl IdentifierChar for char { if self < '\u{0080}' { self.ascii_may_continue_id() } else { - use MajorCategory::*; + use unicode_properties::GeneralCategoryGroup::*; - [L, M, S, N].contains(&self.get_major_category()) && self != char::REPLACEMENT_CHARACTER + matches!( + self.general_category_group(), + Letter | Mark | Symbol | Number + ) && self != char::REPLACEMENT_CHARACTER } } }