Skip to content

web search done right

remove once_cell dep as it is now part of std

Mikkel Denker119403b7e1dd
diff --git a/Cargo.lock b/Cargo.lock
index 2c2c489f..46181efb 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3314,7 +3314,6 @@ dependencies = [
"lalrpop",
"lalrpop-util",
"logos",
- "once_cell",
"serde",
"thiserror",
"utoipa",
@@ -4962,7 +4961,6 @@ dependencies = [
"nom",
"num-bigint",
"num-rational",
- "once_cell",
"openraft",
"optics",
"percent-encoding",
@@ -5233,7 +5231,6 @@ dependencies = [
"more-asserts",
"murmurhash32",
"nom",
- "once_cell",
"oneshot",
"ownedbytes",
"paste",
diff --git a/Cargo.toml b/Cargo.toml
index 2bdd00ec..85f87514 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -110,7 +110,6 @@ murmurhash32 = "0.3"
nom = "7.1.3"
num-bigint = "0.4.1"
num-rational = "0.4.1"
-once_cell = "1.13.1"
oneshot = "0.1.7"
openraft = {version = "0.9.1", features = [
"storage-v2",
diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml
index 2aa3cdac..ca502367 100644
--- a/crates/core/Cargo.toml
+++ b/crates/core/Cargo.toml
@@ -69,7 +69,6 @@ min-max-heap.workspace = true
nom.workspace = true
num-bigint.workspace = true
num-rational.workspace = true
-once_cell.workspace = true
openraft.workspace = true
optics = {path = "../optics"}
percent-encoding.workspace = true
diff --git a/crates/core/src/entrypoint/ampc/approximated_harmonic_centrality/mapper.rs b/crates/core/src/entrypoint/ampc/approximated_harmonic_centrality/mapper.rs
index 1008705c..c930dd1a 100644
--- a/crates/core/src/entrypoint/ampc/approximated_harmonic_centrality/mapper.rs
+++ b/crates/core/src/entrypoint/ampc/approximated_harmonic_centrality/mapper.rs
@@ -28,7 +28,7 @@ use rayon::prelude::*;
const BATCH_SIZE: usize = 1024;
const MAX_OUTGOING_EDGES: usize = 128;
-pub static SKIPPED_REL: once_cell::sync::Lazy<RelFlags> = once_cell::sync::Lazy::new(|| {
+pub static SKIPPED_REL: std::sync::LazyLock<RelFlags> = std::sync::LazyLock::new(|| {
RelFlags::TAG
| RelFlags::NOFOLLOW
| RelFlags::IS_IN_FOOTER
diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs
index 37490093..610d2392 100644
--- a/crates/core/src/lib.rs
+++ b/crates/core/src/lib.rs
@@ -90,8 +90,8 @@ pub mod webgraph;
pub mod webpage;
mod widgets;
-static TOKIO_RUNTIME: once_cell::sync::Lazy<tokio::runtime::Runtime> =
- once_cell::sync::Lazy::new(|| {
+static TOKIO_RUNTIME: std::sync::LazyLock<tokio::runtime::Runtime> =
+ std::sync::LazyLock::new(|| {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
diff --git a/crates/core/src/stopwords.rs b/crates/core/src/stopwords.rs
index b7d44d15..2e1f13f6 100644
--- a/crates/core/src/stopwords.rs
+++ b/crates/core/src/stopwords.rs
@@ -35,8 +35,8 @@ macro_rules! include_stopwords {
}};
}
-static STOPWORDS: once_cell::sync::Lazy<HashMap<Lang, HashSet<String>>> =
- once_cell::sync::Lazy::new(|| {
+static STOPWORDS: std::sync::LazyLock<HashMap<Lang, HashSet<String>>> =
+ std::sync::LazyLock::new(|| {
include_stopwords!(
"../stopwords/Afrikaans.txt" => Lang::Afr,
"../stopwords/Arabic.txt" => Lang::Ara,
diff --git a/crates/core/src/ttl_cache.rs b/crates/core/src/ttl_cache.rs
index cfc65522..58de0526 100644
--- a/crates/core/src/ttl_cache.rs
+++ b/crates/core/src/ttl_cache.rs
@@ -105,21 +105,21 @@ mod tests {
#[test]
fn simple() {
- let mut cache = TTLCache::with_ttl_and_max_size(Duration::from_millis(50), None);
+ let mut cache = TTLCache::with_ttl_and_max_size(Duration::from_millis(500), None);
cache.insert(0, 0);
- std::thread::sleep(Duration::from_millis(30));
+ std::thread::sleep(Duration::from_millis(250));
cache.insert(1, 1);
assert_eq!(cache.get(&0), Some(&0));
assert_eq!(cache.get(&1), Some(&1));
- std::thread::sleep(Duration::from_millis(30));
+ std::thread::sleep(Duration::from_millis(300));
assert_eq!(cache.get(&0), None);
assert_eq!(cache.get(&1), Some(&1));
- std::thread::sleep(Duration::from_millis(30));
+ std::thread::sleep(Duration::from_millis(300));
assert_eq!(cache.get(&0), None);
assert_eq!(cache.get(&1), None);
diff --git a/crates/core/src/webgraph/centrality/harmonic.rs b/crates/core/src/webgraph/centrality/harmonic.rs
index 14a21e09..8f82726a 100644
--- a/crates/core/src/webgraph/centrality/harmonic.rs
+++ b/crates/core/src/webgraph/centrality/harmonic.rs
@@ -33,7 +33,7 @@ use crate::{
const HYPERLOGLOG_COUNTERS: usize = 64;
-pub static SKIPPED_REL: once_cell::sync::Lazy<RelFlags> = once_cell::sync::Lazy::new(|| {
+pub static SKIPPED_REL: std::sync::LazyLock<RelFlags> = std::sync::LazyLock::new(|| {
RelFlags::TAG
| RelFlags::NOFOLLOW
| RelFlags::IS_IN_FOOTER
diff --git a/crates/core/src/webpage/adservers.rs b/crates/core/src/webpage/adservers.rs
index 6916c886..1b902262 100644
--- a/crates/core/src/webpage/adservers.rs
+++ b/crates/core/src/webpage/adservers.rs
@@ -17,8 +17,7 @@
use std::collections::HashSet;
const LIST: &str = include_str!("adservers.txt");
-pub static AD_SERVERS: once_cell::sync::Lazy<AdServers> =
- once_cell::sync::Lazy::new(AdServers::new);
+pub static AD_SERVERS: std::sync::LazyLock<AdServers> = std::sync::LazyLock::new(AdServers::new);
pub struct AdServers {
servers: HashSet<String>,
diff --git a/crates/core/src/webpage/html/mod.rs b/crates/core/src/webpage/html/mod.rs
index 4866b327..a7bf0282 100644
--- a/crates/core/src/webpage/html/mod.rs
+++ b/crates/core/src/webpage/html/mod.rs
@@ -38,7 +38,7 @@ mod microformats;
mod parse_text;
mod robots_meta;
-pub static URL_REGEX: once_cell::sync::Lazy<Regex> = once_cell::sync::Lazy::new(|| {
+pub static URL_REGEX: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
Regex::new(r"(((http|ftp|https):/{2})+(([0-9a-z_-]+\.)+(aero|asia|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx|cy|cz|cz|de|dj|dk|dm|do|dz|ec|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mn|mn|mo|mp|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|nom|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ra|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw|arpa)(:[0-9]+)?((/([~0-9a-zA-Z\#\+%@\./_-]+))?(\?[0-9a-zA-Z\+%@/&\[\];=_-]+)?)?))\b").unwrap()
});
diff --git a/crates/core/src/webpage/url_ext.rs b/crates/core/src/webpage/url_ext.rs
index 4a5fe283..12f10e5f 100644
--- a/crates/core/src/webpage/url_ext.rs
+++ b/crates/core/src/webpage/url_ext.rs
@@ -17,13 +17,13 @@
use crate::Result;
use publicsuffix::Psl;
-static PUBLIC_SUFFIX_LIST: once_cell::sync::Lazy<publicsuffix::List> =
- once_cell::sync::Lazy::new(|| {
+static PUBLIC_SUFFIX_LIST: std::sync::LazyLock<publicsuffix::List> =
+ std::sync::LazyLock::new(|| {
include_str!("../../public_suffix_list.dat")
.parse()
.expect("Failed to parse public suffix list")
});
-static ICANN_LIST: once_cell::sync::Lazy<publicsuffix::List> = once_cell::sync::Lazy::new(|| {
+static ICANN_LIST: std::sync::LazyLock<publicsuffix::List> = std::sync::LazyLock::new(|| {
include_str!("../../public_icann_suffix.dat")
.parse()
.expect("Failed to parse public icann suffix list")
diff --git a/crates/core/src/widgets/calculator.rs b/crates/core/src/widgets/calculator.rs
index 66217236..8a4e19c9 100644
--- a/crates/core/src/widgets/calculator.rs
+++ b/crates/core/src/widgets/calculator.rs
@@ -25,8 +25,8 @@ use std::{
};
use utoipa::ToSchema;
-static DICE_REGEX: once_cell::sync::Lazy<regex::Regex> =
- once_cell::sync::Lazy::new(|| regex::Regex::new(r"^d[0-9]+").unwrap());
+static DICE_REGEX: std::sync::LazyLock<regex::Regex> =
+ std::sync::LazyLock::new(|| regex::Regex::new(r"^d[0-9]+").unwrap());
#[derive(
Debug, serde::Serialize, serde::Deserialize, bincode::Encode, bincode::Decode, ToSchema,
diff --git a/crates/core/src/widgets/thesaurus.rs b/crates/core/src/widgets/thesaurus.rs
index ba037195..241d8fe9 100644
--- a/crates/core/src/widgets/thesaurus.rs
+++ b/crates/core/src/widgets/thesaurus.rs
@@ -29,9 +29,8 @@ use rio_api::parser::TriplesParser;
use rio_turtle::TurtleParser;
use std::collections::HashMap;
-static VALUE_STR_REGEX: once_cell::sync::Lazy<Regex> = once_cell::sync::Lazy::new(|| {
- regex::Regex::new(r#""(.*)"@"#).expect("Failed to compile regex")
-});
+static VALUE_STR_REGEX: std::sync::LazyLock<Regex> =
+ std::sync::LazyLock::new(|| regex::Regex::new(r#""(.*)"@"#).expect("Failed to compile regex"));
#[derive(
Debug,
diff --git a/crates/optics/Cargo.toml b/crates/optics/Cargo.toml
index 3d050d35..03f5d55e 100644
--- a/crates/optics/Cargo.toml
+++ b/crates/optics/Cargo.toml
@@ -1,18 +1,17 @@
[package]
-name = "optics"
-version = "0.1.0"
edition = "2021"
license = "MIT"
+name = "optics"
+version = "0.1.0"
[dependencies]
-thiserror = { workspace = true }
-lalrpop-util = { workspace = true }
-once_cell = { workspace = true }
-itertools = { workspace = true }
-logos = { workspace = true }
-serde = { workspace = true }
-utoipa = { workspace = true }
-bincode = { workspace = true }
+bincode = {workspace = true}
+itertools = {workspace = true}
+lalrpop-util = {workspace = true}
+logos = {workspace = true}
+serde = {workspace = true}
+thiserror = {workspace = true}
+utoipa = {workspace = true}
[build-dependencies]
-lalrpop = { workspace = true }
+lalrpop = {workspace = true}
diff --git a/crates/optics/src/ast.rs b/crates/optics/src/ast.rs
index e8c47c31..17fe4e10 100644
--- a/crates/optics/src/ast.rs
+++ b/crates/optics/src/ast.rs
@@ -22,8 +22,8 @@ use super::lexer;
lalrpop_mod!(pub parser, "/parser.rs");
-pub static PARSER: once_cell::sync::Lazy<parser::BlocksParser> =
- once_cell::sync::Lazy::new(parser::BlocksParser::new);
+pub static PARSER: std::sync::LazyLock<parser::BlocksParser> =
+ std::sync::LazyLock::new(parser::BlocksParser::new);
#[derive(Debug, PartialEq)]
pub struct RawOptic {
diff --git a/crates/tantivy/Cargo.toml b/crates/tantivy/Cargo.toml
index 07f1498f..84377f2e 100644
--- a/crates/tantivy/Cargo.toml
+++ b/crates/tantivy/Cargo.toml
@@ -40,7 +40,6 @@ measure_time.workspace = true
memmap2 = {workspace = true, optional = true}
murmurhash32.workspace = true
nom.workspace = true
-once_cell.workspace = true
oneshot.workspace = true
ownedbytes.workspace = true
rayon.workspace = true
diff --git a/crates/tantivy/src/columnfield/mod.rs b/crates/tantivy/src/columnfield/mod.rs
index 794a3a0a..8d79074f 100644
--- a/crates/tantivy/src/columnfield/mod.rs
+++ b/crates/tantivy/src/columnfield/mod.rs
@@ -75,10 +75,10 @@ mod tests {
use std::path::Path;
use crate::common::{ByteCount, DateTimePrecision, HasLen, TerminatingWrite};
- use once_cell::sync::Lazy;
use rand::prelude::SliceRandom;
use rand::rngs::StdRng;
use rand::{Rng, SeedableRng};
+ use std::sync::LazyLock;
use super::*;
use crate::directory::{Directory, RamDirectory, WritePtr};
@@ -91,12 +91,12 @@ mod tests {
use crate::time::OffsetDateTime;
use crate::{Index, IndexWriter, SegmentReader};
- pub static SCHEMA: Lazy<Schema> = Lazy::new(|| {
+ pub static SCHEMA: LazyLock<Schema> = LazyLock::new(|| {
let mut schema_builder = Schema::builder();
schema_builder.add_u64_field("field", COLUMN);
schema_builder.build()
});
- pub static FIELD: Lazy<Field> = Lazy::new(|| SCHEMA.get_field("field").unwrap());
+ pub static FIELD: LazyLock<Field> = LazyLock::new(|| SCHEMA.get_field("field").unwrap());
#[test]
pub fn test_convert_i64_u64() {
diff --git a/crates/tantivy/src/core/mod.rs b/crates/tantivy/src/core/mod.rs
index db4ab289..da0e7200 100644
--- a/crates/tantivy/src/core/mod.rs
+++ b/crates/tantivy/src/core/mod.rs
@@ -5,21 +5,21 @@ pub mod searcher;
use std::path::Path;
-use once_cell::sync::Lazy;
+use std::sync::LazyLock;
pub use self::executor::Executor;
pub use self::searcher::{Searcher, SearcherGeneration};
/// The meta file contains all the information about the list of segments and the schema
/// of the index.
-pub static META_FILEPATH: Lazy<&'static Path> = Lazy::new(|| Path::new("meta.json"));
+pub static META_FILEPATH: LazyLock<&'static Path> = LazyLock::new(|| Path::new("meta.json"));
/// The managed file contains a list of files that were created by the tantivy
/// and will therefore be garbage collected when they are deemed useless by tantivy.
///
/// Removing this file is safe, but will prevent the garbage collection of all of the file that
/// are currently in the directory
-pub static MANAGED_FILEPATH: Lazy<&'static Path> = Lazy::new(|| Path::new(".managed.json"));
+pub static MANAGED_FILEPATH: LazyLock<&'static Path> = LazyLock::new(|| Path::new(".managed.json"));
#[cfg(test)]
mod tests;
diff --git a/crates/tantivy/src/directory/directory_lock.rs b/crates/tantivy/src/directory/directory_lock.rs
index c5ed8ade..67a4cada 100644
--- a/crates/tantivy/src/directory/directory_lock.rs
+++ b/crates/tantivy/src/directory/directory_lock.rs
@@ -1,6 +1,6 @@
use std::path::PathBuf;
-use once_cell::sync::Lazy;
+use std::sync::LazyLock;
/// A directory lock.
///
@@ -42,7 +42,7 @@ pub struct Lock {
/// (creating more than one instance of the `IndexWriter`), are a spurious
/// lock file remaining after a crash. In the latter case, removing the file after
/// checking no process running tantivy is running is safe.
-pub static INDEX_WRITER_LOCK: Lazy<Lock> = Lazy::new(|| Lock {
+pub static INDEX_WRITER_LOCK: LazyLock<Lock> = LazyLock::new(|| Lock {
filepath: PathBuf::from(".tantivy-writer.lock"),
is_blocking: false,
});
@@ -53,7 +53,7 @@ pub static INDEX_WRITER_LOCK: Lazy<Lock> = Lazy::new(|| Lock {
/// here, but it is difficult to achieve on Windows.
///
/// Opening segment readers is a very fast process.
-pub static META_LOCK: Lazy<Lock> = Lazy::new(|| Lock {
+pub static META_LOCK: LazyLock<Lock> = LazyLock::new(|| Lock {
filepath: PathBuf::from(".tantivy-meta.lock"),
is_blocking: true,
});
diff --git a/crates/tantivy/src/fieldnorm/mod.rs b/crates/tantivy/src/fieldnorm/mod.rs
index 75fcff1e..534dcc56 100644
--- a/crates/tantivy/src/fieldnorm/mod.rs
+++ b/crates/tantivy/src/fieldnorm/mod.rs
@@ -30,7 +30,7 @@ pub use self::writer::FieldNormsWriter;
mod tests {
use std::path::Path;
- use once_cell::sync::Lazy;
+ use std::sync::LazyLock;
use crate::directory::{CompositeFile, Directory, RamDirectory, WritePtr};
use crate::fieldnorm::{FieldNormReader, FieldNormsSerializer, FieldNormsWriter};
@@ -40,7 +40,7 @@ mod tests {
};
use crate::{Index, Term, TERMINATED};
- pub static SCHEMA: Lazy<Schema> = Lazy::new(|| {
+ pub static SCHEMA: LazyLock<Schema> = LazyLock::new(|| {
let mut schema_builder = Schema::builder();
schema_builder.add_text_field("field", STORED);
schema_builder.add_text_field("txt_field", TEXT);
@@ -55,9 +55,11 @@ mod tests {
schema_builder.build()
});
- pub static FIELD: Lazy<Field> = Lazy::new(|| SCHEMA.get_field("field").unwrap());
- pub static TXT_FIELD: Lazy<Field> = Lazy::new(|| SCHEMA.get_field("txt_field").unwrap());
- pub static STR_FIELD: Lazy<Field> = Lazy::new(|| SCHEMA.get_field("str_field").unwrap());
+ pub static FIELD: LazyLock<Field> = LazyLock::new(|| SCHEMA.get_field("field").unwrap());
+ pub static TXT_FIELD: LazyLock<Field> =
+ LazyLock::new(|| SCHEMA.get_field("txt_field").unwrap());
+ pub static STR_FIELD: LazyLock<Field> =
+ LazyLock::new(|| SCHEMA.get_field("str_field").unwrap());
#[test]
#[should_panic(expected = "Cannot register a given fieldnorm twice")]
diff --git a/crates/tantivy/src/index/segment_id.rs b/crates/tantivy/src/index/segment_id.rs
index e66aa95a..49a13b97 100644
--- a/crates/tantivy/src/index/segment_id.rs
+++ b/crates/tantivy/src/index/segment_id.rs
@@ -5,9 +5,9 @@ use std::str::FromStr;
#[cfg(test)]
use std::sync::atomic;
-#[cfg(test)]
-use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
+#[cfg(test)]
+use std::sync::LazyLock;
use uuid::Uuid;
/// Uuid identifying a segment.
@@ -22,7 +22,8 @@ use uuid::Uuid;
pub struct SegmentId(Uuid);
#[cfg(test)]
-static AUTO_INC_COUNTER: Lazy<atomic::AtomicUsize> = Lazy::new(atomic::AtomicUsize::default);
+static AUTO_INC_COUNTER: LazyLock<atomic::AtomicUsize> =
+ LazyLock::new(atomic::AtomicUsize::default);
#[cfg(test)]
const ZERO_ARRAY: [u8; 8] = [0u8; 8];
diff --git a/crates/tantivy/src/indexer/log_merge_policy.rs b/crates/tantivy/src/indexer/log_merge_policy.rs
index 86a8fd34..fa571f21 100644
--- a/crates/tantivy/src/indexer/log_merge_policy.rs
+++ b/crates/tantivy/src/indexer/log_merge_policy.rs
@@ -141,14 +141,14 @@ impl Default for LogMergePolicy {
#[cfg(test)]
mod tests {
- use once_cell::sync::Lazy;
+ use std::sync::LazyLock;
use super::*;
use crate::index::{SegmentId, SegmentMetaInventory};
use crate::schema;
use crate::schema::INDEXED;
- static INVENTORY: Lazy<SegmentMetaInventory> = Lazy::new(SegmentMetaInventory::default);
+ static INVENTORY: LazyLock<SegmentMetaInventory> = LazyLock::new(SegmentMetaInventory::default);
use crate::Index;
diff --git a/crates/tantivy/src/lib.rs b/crates/tantivy/src/lib.rs
index 62d992d2..d1085af1 100644
--- a/crates/tantivy/src/lib.rs
+++ b/crates/tantivy/src/lib.rs
@@ -129,11 +129,10 @@ pub use self::reader::{IndexReader, IndexReaderBuilder, ReloadPolicy, Warmer};
pub mod snippet;
mod docset;
-use std::fmt;
+use std::{fmt, sync::LazyLock};
pub use crate::common::{f64_to_u64, i64_to_u64, u64_to_f64, u64_to_i64, HasLen};
pub use census::{Inventory, TrackedObject};
-use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
pub use self::docset::{DocSet, COLLECT_BLOCK_BUFFER_LEN, TERMINATED};
@@ -168,7 +167,7 @@ impl fmt::Debug for Version {
}
}
-static VERSION: Lazy<Version> = Lazy::new(|| Version {
+static VERSION: LazyLock<Version> = LazyLock::new(|| Version {
major: env!("CARGO_PKG_VERSION_MAJOR").parse().unwrap(),
minor: env!("CARGO_PKG_VERSION_MINOR").parse().unwrap(),
patch: env!("CARGO_PKG_VERSION_PATCH").parse().unwrap(),
@@ -185,7 +184,7 @@ impl fmt::Display for Version {
}
}
-static VERSION_STRING: Lazy<String> = Lazy::new(|| VERSION.to_string());
+static VERSION_STRING: LazyLock<String> = LazyLock::new(|| VERSION.to_string());
/// Expose the current version of tantivy as found in Cargo.toml during compilation.
/// eg. "0.11.0" as well as the compression scheme used in the docstore.
diff --git a/crates/tantivy/src/query/fuzzy_query.rs b/crates/tantivy/src/query/fuzzy_query.rs
index ff27b6d1..cd2c1cc8 100644
--- a/crates/tantivy/src/query/fuzzy_query.rs
+++ b/crates/tantivy/src/query/fuzzy_query.rs
@@ -1,6 +1,6 @@
use fst::Automaton;
use levenshtein_automata::{Distance, LevenshteinAutomatonBuilder, DFA};
-use once_cell::sync::OnceCell;
+use std::sync::OnceLock;
use crate::query::{AutomatonWeight, EnableScoring, Query, Weight};
use crate::schema::{Term, Type};
@@ -110,10 +110,10 @@ impl FuzzyTermQuery {
}
fn specialized_weight(&self) -> crate::Result<AutomatonWeight<DfaWrapper>> {
- static AUTOMATON_BUILDER: [[OnceCell<LevenshteinAutomatonBuilder>; 2]; 3] = [
- [OnceCell::new(), OnceCell::new()],
- [OnceCell::new(), OnceCell::new()],
- [OnceCell::new(), OnceCell::new()],
+ static AUTOMATON_BUILDER: [[OnceLock<LevenshteinAutomatonBuilder>; 2]; 3] = [
+ [OnceLock::new(), OnceLock::new()],
+ [OnceLock::new(), OnceLock::new()],
+ [OnceLock::new(), OnceLock::new()],
];
let automaton_builder = AUTOMATON_BUILDER
diff --git a/crates/tantivy/src/termdict/fst_termdict/termdict.rs b/crates/tantivy/src/termdict/fst_termdict/termdict.rs
index 18d9028e..7937fbdd 100644
--- a/crates/tantivy/src/termdict/fst_termdict/termdict.rs
+++ b/crates/tantivy/src/termdict/fst_termdict/termdict.rs
@@ -3,7 +3,7 @@ use std::io::{self, Write};
use crate::common::{BinarySerializable, CountingWriter};
use fst::raw::Fst;
use fst::Automaton;
-use once_cell::sync::Lazy;
+use std::sync::LazyLock;
use super::term_info_store::{TermInfoStore, TermInfoStoreWriter};
use super::{TermStreamer, TermStreamerBuilder};
@@ -100,7 +100,7 @@ fn open_fst_index(fst_file: FileSlice) -> io::Result<fst::Map<OwnedBytes>> {
Ok(fst::Map::from(fst))
}
-static EMPTY_TERM_DICT_FILE: Lazy<FileSlice> = Lazy::new(|| {
+static EMPTY_TERM_DICT_FILE: LazyLock<FileSlice> = LazyLock::new(|| {
let term_dictionary_data: Vec<u8> = TermDictionaryBuilder::create(Vec::<u8>::new())
.expect("Creating a TermDictionaryBuilder in a Vec<u8> should never fail")
.finish()