Skip to content

Commit

Permalink
feat: use std one cell
Browse files Browse the repository at this point in the history
  • Loading branch information
fengkx committed Oct 12, 2024
1 parent 1b31581 commit e02a5f4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ default = ["console_error_panic_hook", "wee_alloc"]
[dependencies]
wasm-bindgen = { version = "0.2.63", features = ["serde-serialize"] }
jieba-rs = { path = "./jieba-rs", features = ["tfidf", "textrank"] }
lazy_static = "1.4.0"
serde-wasm-bindgen = "0.1.3"
serde = { version = "1.0", features = ["derive"] }
# The `console_error_panic_hook` crate provides better debugging of panics by
Expand Down
7 changes: 2 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use jieba_rs::Jieba;
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use std::sync::Mutex;
use std::sync::{LazyLock, Mutex};
use wasm_bindgen::prelude::*;

// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
Expand All @@ -20,9 +19,7 @@ pub struct RetToken<'a> {
pub end: usize,
}

lazy_static! {
pub static ref JIEBA: Mutex<Jieba> = Mutex::new(Jieba::new());
}
static JIEBA: LazyLock<Mutex<Jieba>> = LazyLock::new(|| Mutex::new(Jieba::new()));

#[wasm_bindgen]
pub fn cut(text: &str, hmm: Option<bool>) -> Vec<JsValue> {
Expand Down

0 comments on commit e02a5f4

Please sign in to comment.