Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
fix(thesaurus): MacOS builds by using `ruzstd` (#2490)
Elijah Potter07e5ef86ddce
diff --git a/Cargo.lock b/Cargo.lockindex 212f02ab4..6a577274c 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2919,6 +2919,7 @@ dependencies = ["hashbrown 0.16.1","indexmap","itertools 0.14.0",+ "ruzstd","zstd",]@@ -4793,6 +4794,15 @@ version = "1.0.21"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d"+[[package]]+name = "ruzstd"+version = "0.8.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e5ff0cc5e135c8870a775d3320910cd9b564ec036b4dc0b8741629020be63f01"+dependencies = [+ "twox-hash",+]+[[package]]name = "ryu"version = "1.0.20"@@ -6078,6 +6088,12 @@ version = "0.2.5"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"+[[package]]+name = "twox-hash"+version = "2.1.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9ea3136b675547379c4bd395ca6b938e5ad3c3d20fad76e7fe85f9e0d011419c"+[[package]]name = "type-map"version = "0.5.1"diff --git a/harper-thesaurus/Cargo.toml b/harper-thesaurus/Cargo.tomlindex 9bdbecd45..77c89f8d2 100644--- a/harper-thesaurus/Cargo.toml+++ b/harper-thesaurus/Cargo.toml@@ -10,7 +10,7 @@ repository = "https://github.com/automattic/harper"hashbrown = "0.16.0"indexmap = "2.12.1"itertools = "0.14.0"-zstd = { version = "0.13.3", default-features = false }+ruzstd = "0.8.2"[build-dependencies]zstd = { version = "0.13.3", default-features = false }diff --git a/harper-thesaurus/src/thesaurus.rs b/harper-thesaurus/src/thesaurus.rsindex b19d4b0bd..b064f909b 100644--- a/harper-thesaurus/src/thesaurus.rs+++ b/harper-thesaurus/src/thesaurus.rs@@ -1,7 +1,9 @@+use ruzstd::io::Read;use std::sync::OnceLock;use hashbrown::HashMap;use indexmap::IndexSet;+use ruzstd::decoding::StreamingDecoder;static COMPRESSED_THESAURUS: &[u8] =include_bytes!(concat!(env!("OUT_DIR"), "/compressed-thesaurus.zst"));@@ -38,9 +40,12 @@ impl Thesaurus {let mut entries = HashMap::new();let mut deduped_word_set = IndexSet::<String>::new();- let raw_thesaurus_text = zstd::stream::decode_all(COMPRESSED_THESAURUS)- .expect("Compressed thesaurus is a valid ZSTD file")- .into_boxed_slice();+ let mut decoder = StreamingDecoder::new(COMPRESSED_THESAURUS).unwrap();+ let mut raw_thesaurus_text = Vec::new();+ decoder+ .read_to_end(&mut raw_thesaurus_text)+ .expect("Compressed thesaurus is a valid ZSTD file");+let raw_thesaurus_text =str::from_utf8(&raw_thesaurus_text).expect("Thesaurus content is valid UTF-8");