Replace lazy_static with std::sync::LazyLock (#16066)

Closes #15860 

Since rust std now supports LazyLock replacing lazy_static with it
reduce the external dependency.

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This commit is contained in:
Sinan Gençoğlu 2024-08-20 20:27:33 +02:00 committed by GitHub
parent 85731dfe8e
commit ff7017c308
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 160 additions and 195 deletions

View file

@ -19,7 +19,6 @@ test-support = ["rand"]
anyhow.workspace = true
clock.workspace = true
collections.workspace = true
lazy_static.workspace = true
log.workspace = true
parking_lot.workspace = true
postage.workspace = true

View file

@ -1,11 +1,9 @@
use lazy_static::lazy_static;
use smallvec::{smallvec, SmallVec};
use std::iter;
use std::sync::LazyLock;
lazy_static! {
static ref MIN: Locator = Locator::min();
static ref MAX: Locator = Locator::max();
}
static MIN: LazyLock<Locator> = LazyLock::new(|| Locator::min());
static MAX: LazyLock<Locator> = LazyLock::new(|| Locator::max());
/// An identifier for a position in a ordered collection.
///

View file

@ -19,7 +19,6 @@ use operation_queue::OperationQueue;
pub use patch::Patch;
use postage::{oneshot, prelude::*};
use lazy_static::lazy_static;
use regex::Regex;
pub use rope::*;
pub use selection::*;
@ -32,7 +31,7 @@ use std::{
num::NonZeroU64,
ops::{self, Deref, Range, Sub},
str,
sync::Arc,
sync::{Arc, LazyLock},
time::{Duration, Instant},
};
pub use subscription::*;
@ -44,9 +43,9 @@ use util::ResultExt;
#[cfg(any(test, feature = "test-support"))]
use util::RandomCharIter;
lazy_static! {
static ref LINE_SEPARATORS_REGEX: Regex = Regex::new("\r\n|\r|\u{2028}|\u{2029}").unwrap();
}
static LINE_SEPARATORS_REGEX: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(r"\r\n|\r|\u{2028}|\u{2029}").expect("Failed to create LINE_SEPARATORS_REGEX")
});
pub type TransactionId = clock::Lamport;