Skip to content

Commit fecb908

Browse files
committed
chore: Replace once_cell dependency by std lib
LazyLock is introduced in rust 1.80
1 parent d38072f commit fecb908

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ authors = [
3131
]
3232
license = "Apache-2.0"
3333
repository = "https://github.com/tokio-rs/prost"
34-
rust-version = "1.70"
34+
rust-version = "1.80"
3535
edition = "2021"
3636

3737
[profile.bench]

prost-build/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ petgraph = { version = "0.6", default-features = false }
2424
prost = { version = "0.13.1", path = "../prost", default-features = false }
2525
prost-types = { version = "0.13.1", path = "../prost-types", default-features = false }
2626
tempfile = "3"
27-
once_cell = "1.17.1"
2827
regex = { version = "1.8.1", default-features = false, features = ["std", "unicode-bool"] }
2928

3029
# feature: format

prost-build/src/ast.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use once_cell::sync::Lazy;
21
use prost_types::source_code_info::Location;
32
#[cfg(feature = "cleanup-markdown")]
43
use pulldown_cmark::{CodeBlockKind, Event, Options, Parser, Tag};
54
use regex::Regex;
5+
use std::sync::LazyLock;
66

77
/// Comments on a Protobuf item.
88
#[derive(Debug, Default, Clone)]
@@ -110,9 +110,10 @@ impl Comments {
110110
/// - escape urls as <http://foo.com>
111111
/// - escape `[` & `]` if not already escaped and not followed by a parenthesis or bracket
112112
fn sanitize_line(line: &str) -> String {
113-
static RULE_URL: Lazy<Regex> = Lazy::new(|| Regex::new(r"https?://[^\s)]+").unwrap());
114-
static RULE_BRACKETS: Lazy<Regex> =
115-
Lazy::new(|| Regex::new(r"(^|[^\]\\])\[(([^\]]*[^\\])?)\]([^(\[]|$)").unwrap());
113+
static RULE_URL: LazyLock<Regex> =
114+
LazyLock::new(|| Regex::new(r"https?://[^\s)]+").unwrap());
115+
static RULE_BRACKETS: LazyLock<Regex> =
116+
LazyLock::new(|| Regex::new(r"(^|[^\]\\])\[(([^\]]*[^\\])?)\]([^(\[]|$)").unwrap());
116117

117118
let mut s = RULE_URL.replace_all(line, r"<$0>").to_string();
118119
s = RULE_BRACKETS.replace_all(&s, r"$1\[$2\]$4").to_string();

0 commit comments

Comments
 (0)