Skip to content

Commit 72f4888

Browse files
committed
Use once_cell instead of lazystatic in tests/openssh.rs
Signed-off-by: Jiahao XU <[email protected]>
1 parent 07c47fb commit 72f4888

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tests/openssh.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use lazy_static::lazy_static;
1+
use once_cell::sync::Lazy;
22
use regex::Regex;
33
use std::env;
44
use std::io;
@@ -136,12 +136,12 @@ struct ProtoUserHostPort<'a> {
136136
}
137137

138138
fn parse_user_host_port(s: &str) -> Option<ProtoUserHostPort> {
139-
lazy_static! {
140-
static ref SSH_REGEX: Regex = Regex::new(
141-
r"(?x)^((?P<proto>[[:alpha:]]+)://)?((?P<user>.*?)@)?(?P<host>.*?)(:(?P<port>\d+))?$"
139+
static SSH_REGEX: Lazy<Regex> = Lazy::new(|| {
140+
Regex::new(
141+
r"(?x)^((?P<proto>[[:alpha:]]+)://)?((?P<user>.*?)@)?(?P<host>.*?)(:(?P<port>\d+))?$",
142142
)
143-
.unwrap();
144-
}
143+
.unwrap()
144+
});
145145

146146
SSH_REGEX.captures(s).map(|cap| ProtoUserHostPort {
147147
proto: cap.name("proto").map(|m| m.as_str()),

0 commit comments

Comments
 (0)