Skip to content

Commit 34b1e3d

Browse files
authored
Drop once_cell because of MSRV bump (#137)
1 parent ba208a0 commit 34b1e3d

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ windows-console-colors = ["ansi-parsing", "regex", "winapi-util"]
1717
ansi-parsing = []
1818

1919
[dependencies]
20-
once_cell = "1"
2120
libc = "0.2.30"
2221
terminal_size = "0.1.14"
2322
regex = { version = "1.4.2", optional = true, default-features = false, features = ["std"] }
2423
unicode-width = { version = "0.1", optional = true }
24+
lazy_static = "1.4.0"
2525

2626
[target.'cfg(windows)'.dependencies]
2727
winapi = { version = "0.3", features = ["winbase", "winuser", "consoleapi", "processenv", "wincon"] }

src/ansi.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -271,18 +271,18 @@ impl<'a> FusedIterator for AnsiCodeIterator<'a> {}
271271
mod tests {
272272
use super::*;
273273

274-
use once_cell::sync::Lazy;
274+
use lazy_static::lazy_static;
275275
use proptest::prelude::*;
276276
use regex::Regex;
277277

278278
// The manual dfa `State` is a handwritten translation from the previously used regex. That
279279
// regex is kept here and used to ensure that the new matches are the same as the old
280-
static STRIP_ANSI_RE: Lazy<Regex> = Lazy::new(|| {
281-
Regex::new(
282-
r"[\x1b\x9b]([()][012AB]|[\[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><])",
283-
)
284-
.unwrap()
285-
});
280+
lazy_static! {
281+
static ref STRIP_ANSI_RE: Regex = Regex::new(
282+
r"[\x1b\x9b]([()][012AB]|[\[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><])",
283+
)
284+
.unwrap();
285+
}
286286

287287
impl<'a, 'b> PartialEq<Match<'a>> for regex::Match<'b> {
288288
fn eq(&self, other: &Match<'a>) -> bool {

src/unix_term.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,12 @@ pub fn key_from_utf8(buf: &[u8]) -> Key {
271271
}
272272

273273
#[cfg(not(target_os = "macos"))]
274-
static IS_LANG_UTF8: once_cell::sync::Lazy<bool> =
275-
once_cell::sync::Lazy::new(|| match std::env::var("LANG") {
274+
lazy_static::lazy_static! {
275+
static ref IS_LANG_UTF8: bool = match std::env::var("LANG") {
276276
Ok(lang) => lang.to_uppercase().ends_with("UTF-8"),
277277
_ => false,
278-
});
278+
};
279+
}
279280

280281
#[cfg(target_os = "macos")]
281282
pub fn wants_emoji() -> bool {

src/utils.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ use std::env;
44
use std::fmt;
55
use std::sync::atomic::{AtomicBool, Ordering};
66

7+
use lazy_static::lazy_static;
8+
79
use crate::term::{wants_emoji, Term};
8-
use once_cell::sync::Lazy;
910

1011
#[cfg(feature = "ansi-parsing")]
1112
use crate::ansi::{strip_ansi_codes, AnsiCodeIterator};
@@ -21,10 +22,10 @@ fn default_colors_enabled(out: &Term) -> bool {
2122
|| &env::var("CLICOLOR_FORCE").unwrap_or_else(|_| "0".into()) != "0"
2223
}
2324

24-
static STDOUT_COLORS: Lazy<AtomicBool> =
25-
Lazy::new(|| AtomicBool::new(default_colors_enabled(&Term::stdout())));
26-
static STDERR_COLORS: Lazy<AtomicBool> =
27-
Lazy::new(|| AtomicBool::new(default_colors_enabled(&Term::stderr())));
25+
lazy_static! {
26+
static ref STDOUT_COLORS: AtomicBool = AtomicBool::new(default_colors_enabled(&Term::stdout()));
27+
static ref STDERR_COLORS: AtomicBool = AtomicBool::new(default_colors_enabled(&Term::stderr()));
28+
}
2829

2930
/// Returns `true` if colors should be enabled for stdout.
3031
///

src/windows_term.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,15 @@ use crate::common_term;
3737
use crate::kb::Key;
3838
use crate::term::{Term, TermTarget};
3939

40-
#[cfg(feature = "windows-console-colors")]
41-
use once_cell::sync::Lazy;
4240
#[cfg(feature = "windows-console-colors")]
4341
use regex::Regex;
42+
4443
#[cfg(feature = "windows-console-colors")]
45-
static INTENSE_COLOR_RE: Lazy<Regex> =
46-
Lazy::new(|| Regex::new(r"\x1b\[(3|4)8;5;(8|9|1[0-5])m").unwrap());
47-
#[cfg(feature = "windows-console-colors")]
48-
static NORMAL_COLOR_RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"\x1b\[(3|4)([0-7])m").unwrap());
49-
#[cfg(feature = "windows-console-colors")]
50-
static ATTR_RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"\x1b\[([1-8])m").unwrap());
44+
lazy_static::lazy_static! {
45+
static ref INTENSE_COLOR_RE: Regex = Regex::new(r"\x1b\[(3|4)8;5;(8|9|1[0-5])m").unwrap();
46+
static ref NORMAL_COLOR_RE: Regex = Regex::new(r"\x1b\[(3|4)([0-7])m").unwrap();
47+
static ref ATTR_RE: Regex = Regex::new(r"\x1b\[([1-8])m").unwrap();
48+
}
5149

5250
const ENABLE_VIRTUAL_TERMINAL_PROCESSING: u32 = 0x4;
5351
pub const DEFAULT_WIDTH: u16 = 79;

0 commit comments

Comments
 (0)