Skip to content

Commit d397a5d

Browse files
committed
Replace lazy_static with LazyLock
1 parent 9726952 commit d397a5d

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ edition = "2018"
1111

1212
[dependencies]
1313
regex = "1"
14-
lazy_static = "1"
1514
html5ever = "0.31"

src/rules/predefined.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
55
use super::pattern::Pattern;
66
use super::{Element, Rules};
7-
use lazy_static::lazy_static;
87
use regex::Regex;
8+
use std::sync::LazyLock;
99

1010
fn re(regex: &str) -> Pattern {
1111
Pattern::regex(Regex::new(regex).unwrap())
@@ -19,22 +19,20 @@ fn src() -> Pattern {
1919
re("^(http:|https:)") | !re("^[^/]+[[:space:]]*:")
2020
}
2121

22-
lazy_static! {
23-
/// Basic rules. Allows a variety of markup including formatting elements, links, and lists.
24-
pub static ref BASIC: Rules = basic();
22+
/// Basic rules. Allows a variety of markup including formatting elements, links, and lists.
23+
pub static BASIC: LazyLock<Rules> = LazyLock::new(|| basic());
2524

26-
/// Default rules. Removes all tags.
27-
pub static ref DEFAULT: Rules = default();
25+
/// Default rules. Removes all tags.
26+
pub static DEFAULT: LazyLock<Rules> = LazyLock::new(|| default());
2827

29-
/// Relaxed rules. Allows an even wider variety of markup, including images and tables
30-
pub static ref RELAXED: Rules = relaxed();
28+
/// Relaxed rules. Allows an even wider variety of markup, including images and tables
29+
pub static RELAXED: LazyLock<Rules> = LazyLock::new(|| relaxed());
3130

32-
/// Restricted rules. Allows only very simple inline markup. No links, images, or block elements.
33-
pub static ref RESTRICTED: Rules = restricted();
31+
/// Restricted rules. Allows only very simple inline markup. No links, images, or block elements.
32+
pub static RESTRICTED: LazyLock<Rules> = LazyLock::new(|| restricted());
3433

35-
/// Rules for document from untrusted sources. Removes all tags but text emphasizing and links.
36-
pub static ref UNTRUSTED: Rules = untrusted();
37-
}
34+
/// Rules for document from untrusted sources. Removes all tags but text emphasizing and links.
35+
pub static UNTRUSTED: LazyLock<Rules> = LazyLock::new(|| untrusted());
3836

3937
fn basic() -> Rules {
4038
Rules::new()

0 commit comments

Comments
 (0)