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:
parent
6601810d2b
commit
c32d70ac06
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -360,7 +360,6 @@ dependencies = [
|
|||||||
"eyre",
|
"eyre",
|
||||||
"gumdrop",
|
"gumdrop",
|
||||||
"ignore",
|
"ignore",
|
||||||
"lazy_static",
|
|
||||||
"matter",
|
"matter",
|
||||||
"pathdiff",
|
"pathdiff",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
|
@ -28,7 +28,6 @@ doc = false
|
|||||||
eyre = "0.6.12"
|
eyre = "0.6.12"
|
||||||
gumdrop = "0.8.1"
|
gumdrop = "0.8.1"
|
||||||
ignore = "0.4.22"
|
ignore = "0.4.22"
|
||||||
lazy_static = "1.5.0"
|
|
||||||
matter = "0.1.0-alpha4"
|
matter = "0.1.0-alpha4"
|
||||||
pathdiff = "0.2.1"
|
pathdiff = "0.2.1"
|
||||||
percent-encoding = "2.3.1"
|
percent-encoding = "2.3.1"
|
||||||
|
13
src/lib.rs
13
src/lib.rs
@ -1,8 +1,5 @@
|
|||||||
pub use {pulldown_cmark, serde_yaml};
|
pub use {pulldown_cmark, serde_yaml};
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate lazy_static;
|
|
||||||
|
|
||||||
mod context;
|
mod context;
|
||||||
mod frontmatter;
|
mod frontmatter;
|
||||||
pub mod postprocessors;
|
pub mod postprocessors;
|
||||||
@ -898,20 +895,22 @@ fn codeblock_kind_to_owned<'a>(codeblock_kind: CodeBlockKind<'_>) -> CodeBlockKi
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
lazy_static! {
|
static VAULT: LazyLock<Vec<PathBuf>> = LazyLock::new(|| {
|
||||||
static ref VAULT: Vec<PathBuf> = vec![
|
vec![
|
||||||
PathBuf::from("NoteA.md"),
|
PathBuf::from("NoteA.md"),
|
||||||
PathBuf::from("Document.pdf"),
|
PathBuf::from("Document.pdf"),
|
||||||
PathBuf::from("Note.1.md"),
|
PathBuf::from("Note.1.md"),
|
||||||
PathBuf::from("nested/NoteA.md"),
|
PathBuf::from("nested/NoteA.md"),
|
||||||
PathBuf::from("Note\u{E4}.md"), // Noteä.md, see also encodings() below
|
PathBuf::from("Note\u{E4}.md"), // Noteä.md, see also encodings() below
|
||||||
];
|
]
|
||||||
}
|
});
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[allow(clippy::unicode_not_nfc)]
|
#[allow(clippy::unicode_not_nfc)]
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
lazy_static! {
|
static OBSIDIAN_NOTE_LINK_RE: LazyLock<Regex> = LazyLock::new(|| {
|
||||||
static ref OBSIDIAN_NOTE_LINK_RE: Regex =
|
Regex::new(r"^(?P<file>[^#|]+)??(#(?P<section>.+?))??(\|(?P<label>.+?))??$").unwrap()
|
||||||
Regex::new(r"^(?P<file>[^#|]+)??(#(?P<section>.+?))??(\|(?P<label>.+?))??$").unwrap();
|
});
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
/// `ObsidianNoteReference` represents the structure of a `[[note]]` or `![[embed]]` reference.
|
/// `ObsidianNoteReference` represents the structure of a `[[note]]` or `![[embed]]` reference.
|
||||||
|
Loading…
Reference in New Issue
Block a user