Skip to content

Commit

Permalink
chore: Replace once_cell dependency by std lib
Browse files Browse the repository at this point in the history
LazyLock is introduced in rust 1.80
  • Loading branch information
caspermeijn committed Aug 16, 2024
1 parent d38072f commit 8d3c1a1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

env:
PROTOC_VERSION: 3.20.3
clippy_rust_version: 1.79
clippy_rust_version: 1.80

jobs:
# Depends on all actions that are required for a "successful" CI run.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ authors = [
]
license = "Apache-2.0"
repository = "https://github.com/tokio-rs/prost"
rust-version = "1.70"
rust-version = "1.80"
edition = "2021"

[profile.bench]
Expand Down
1 change: 0 additions & 1 deletion prost-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ petgraph = { version = "0.6", default-features = false }
prost = { version = "0.13.1", path = "../prost", default-features = false }
prost-types = { version = "0.13.1", path = "../prost-types", default-features = false }
tempfile = "3"
once_cell = "1.17.1"
regex = { version = "1.8.1", default-features = false, features = ["std", "unicode-bool"] }

# feature: format
Expand Down
9 changes: 5 additions & 4 deletions prost-build/src/ast.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use once_cell::sync::Lazy;
use prost_types::source_code_info::Location;
#[cfg(feature = "cleanup-markdown")]
use pulldown_cmark::{CodeBlockKind, Event, Options, Parser, Tag};
use regex::Regex;
use std::sync::LazyLock;

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

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

0 comments on commit 8d3c1a1

Please sign in to comment.