Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Replace once_cell dependency by std lib #1119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ authors = [
]
license = "Apache-2.0"
repository = "https://github.com/tokio-rs/prost"
rust-version = "1.71.1"
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 @@ -23,7 +23,6 @@ petgraph = { version = "0.6", default-features = false }
prost = { version = "0.13.3", path = "../prost", default-features = false }
prost-types = { version = "0.13.3", 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