Use std::sync::LazyLock instead of lazy_static crate

LazyLock was stabilized in Rust 1.80.0, allowing us to drop this
external dependency now.
This commit is contained in:
Nick Groenen 2024-08-04 11:52:20 +02:00
parent 6601810d2b
commit c32d70ac06
No known key found for this signature in database
GPG Key ID: 4F0AD019928AE098
4 changed files with 10 additions and 13 deletions

1
Cargo.lock generated
View File

@ -360,7 +360,6 @@ dependencies = [
"eyre",
"gumdrop",
"ignore",
"lazy_static",
"matter",
"pathdiff",
"percent-encoding",

View File

@ -28,7 +28,6 @@ doc = false
eyre = "0.6.12"
gumdrop = "0.8.1"
ignore = "0.4.22"
lazy_static = "1.5.0"
matter = "0.1.0-alpha4"
pathdiff = "0.2.1"
percent-encoding = "2.3.1"

View File

@ -1,8 +1,5 @@
pub use {pulldown_cmark, serde_yaml};
#[macro_use]
extern crate lazy_static;
mod context;
mod frontmatter;
pub mod postprocessors;
@ -898,20 +895,22 @@ fn codeblock_kind_to_owned<'a>(codeblock_kind: CodeBlockKind<'_>) -> CodeBlockKi
#[cfg(test)]
mod tests {
use std::sync::LazyLock;
use pretty_assertions::assert_eq;
use rstest::rstest;
use super::*;
lazy_static! {
static ref VAULT: Vec<PathBuf> = vec![
static VAULT: LazyLock<Vec<PathBuf>> = LazyLock::new(|| {
vec![
PathBuf::from("NoteA.md"),
PathBuf::from("Document.pdf"),
PathBuf::from("Note.1.md"),
PathBuf::from("nested/NoteA.md"),
PathBuf::from("Note\u{E4}.md"), // Noteä.md, see also encodings() below
];
}
]
});
#[test]
#[allow(clippy::unicode_not_nfc)]

View File

@ -1,11 +1,11 @@
use std::fmt;
use std::sync::LazyLock;
use regex::Regex;
lazy_static! {
static ref OBSIDIAN_NOTE_LINK_RE: Regex =
Regex::new(r"^(?P<file>[^#|]+)??(#(?P<section>.+?))??(\|(?P<label>.+?))??$").unwrap();
}
static OBSIDIAN_NOTE_LINK_RE: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(r"^(?P<file>[^#|]+)??(#(?P<section>.+?))??(\|(?P<label>.+?))??$").unwrap()
});
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
/// `ObsidianNoteReference` represents the structure of a `[[note]]` or `![[embed]]` reference.