Skip to content

Commit

Permalink
Replace lazy_static with once_cell
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Dec 25, 2023
1 parent c16551b commit 215baee
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion refinery_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ mysql_async = ["dep:mysql_async"]
[dependencies]
async-trait = "0.1"
cfg-if = "1.0"
lazy_static = "1"
log = "0.4"
once_cell = "1"
regex = "1"
serde = { version = "1", features = ["derive"] }
siphasher = "1.0"
Expand Down
5 changes: 2 additions & 3 deletions refinery_core/src/runner.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use once_cell::sync::Lazy;
use regex::Regex;
use siphasher::sip::SipHasher13;
use time::OffsetDateTime;
Expand All @@ -16,9 +17,7 @@ pub fn file_match_re() -> Regex {
Regex::new(r"^([U|V])(\d+(?:\.\d+)?)__(\w+)").unwrap()
}

lazy_static::lazy_static! {
static ref RE: regex::Regex = file_match_re();
}
pub(crate) static RE: Lazy<regex::Regex> = Lazy::new(file_match_re);

/// An enum set that represents the type of the Migration
#[derive(Clone, PartialEq)]
Expand Down
6 changes: 3 additions & 3 deletions refinery_core/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::error::{Error, Kind};
use once_cell::sync::Lazy;
use regex::Regex;
use std::ffi::OsStr;
use std::path::{Path, PathBuf};
use walkdir::{DirEntry, WalkDir};

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

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

0 comments on commit 215baee

Please sign in to comment.