Skip to content

Commit 215baee

Browse files
committed
Replace lazy_static with once_cell
1 parent c16551b commit 215baee

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

refinery_core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ mysql_async = ["dep:mysql_async"]
1919
[dependencies]
2020
async-trait = "0.1"
2121
cfg-if = "1.0"
22-
lazy_static = "1"
2322
log = "0.4"
23+
once_cell = "1"
2424
regex = "1"
2525
serde = { version = "1", features = ["derive"] }
2626
siphasher = "1.0"

refinery_core/src/runner.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use once_cell::sync::Lazy;
12
use regex::Regex;
23
use siphasher::sip::SipHasher13;
34
use time::OffsetDateTime;
@@ -16,9 +17,7 @@ pub fn file_match_re() -> Regex {
1617
Regex::new(r"^([U|V])(\d+(?:\.\d+)?)__(\w+)").unwrap()
1718
}
1819

19-
lazy_static::lazy_static! {
20-
static ref RE: regex::Regex = file_match_re();
21-
}
20+
pub(crate) static RE: Lazy<regex::Regex> = Lazy::new(file_match_re);
2221

2322
/// An enum set that represents the type of the Migration
2423
#[derive(Clone, PartialEq)]

refinery_core/src/util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use crate::error::{Error, Kind};
2+
use once_cell::sync::Lazy;
23
use regex::Regex;
34
use std::ffi::OsStr;
45
use std::path::{Path, PathBuf};
56
use walkdir::{DirEntry, WalkDir};
67

7-
lazy_static::lazy_static! {
8-
static ref RE: regex::Regex = Regex::new(r"^(U|V)(\d+(?:\.\d+)?)__\w+\.(rs|sql)$").unwrap();
9-
}
8+
pub(crate) static RE: Lazy<regex::Regex> =
9+
Lazy::new(|| Regex::new(r"^(U|V)(\d+(?:\.\d+)?)__\w+\.(rs|sql)$").unwrap());
1010

1111
/// enum containing the migration types used to search for migrations
1212
/// either just .sql files or both .sql and .rs

0 commit comments

Comments
 (0)