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

Replace lazy_static with once_cell #119

Closed
wants to merge 2 commits into from
Closed
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 @@ -16,7 +16,7 @@ no-color = []

[dependencies]
atty = "0.2"
lazy_static = "1"
once_cell = "1"

[target.'cfg(windows)'.dependencies.winapi]
version = "0.3"
Expand Down
5 changes: 2 additions & 3 deletions src/control.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! A couple of functions to enable and disable coloring.

use once_cell::sync::Lazy;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming the other crates used in the library have extern crate definitions in the root because of an old Rust version that's being targeted, but I'll have to double check once the crate gets an MSRV figured out (see #85).

This would technically be a breaking change, and I'd probably end up putting this inside a v3 of colored, which is already planned if #139 ends up happening. I'll probably end up making a v2 branch or something, and then I can get this merged in.

use std::default::Default;
use std::env;
use std::sync::atomic::{AtomicBool, Ordering};
Expand Down Expand Up @@ -81,10 +82,8 @@ pub fn unset_override() {
SHOULD_COLORIZE.unset_override()
}

lazy_static! {
/// The persistent [`ShouldColorize`].
pub static ref SHOULD_COLORIZE: ShouldColorize = ShouldColorize::from_env();
}
pub static SHOULD_COLORIZE: Lazy<ShouldColorize> = Lazy::new(ShouldColorize::from_env);

impl Default for ShouldColorize {
fn default() -> ShouldColorize {
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
#![warn(missing_docs)]

extern crate atty;
#[macro_use]
extern crate lazy_static;
#[cfg(windows)]
extern crate winapi;

Expand Down