From cfe8960f3ca3462eebd0c3fcfa14626361a677f7 Mon Sep 17 00:00:00 2001 From: bconn98 Date: Tue, 9 Jul 2024 21:59:56 -0400 Subject: [PATCH] refactor: set_color_mode => get_color_mode --- src/encode/writer/console.rs | 44 ++++++++++++++++++------------------ src/lib.rs | 2 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/encode/writer/console.rs b/src/encode/writer/console.rs index 08f6e63f..f8ae9c0e 100644 --- a/src/encode/writer/console.rs +++ b/src/encode/writer/console.rs @@ -9,7 +9,7 @@ use once_cell::sync::OnceCell; static COLOR_MODE: OnceCell = OnceCell::new(); -fn set_color_mode( +fn get_color_mode( no_color: Result, clicolor_force: Result, clicolor: Result, @@ -129,7 +129,7 @@ mod imp { self, writer::{ ansi::AnsiWriter, - console::{set_color_mode, ColorMode, COLOR_MODE}, + console::{get_color_mode, ColorMode, COLOR_MODE}, }, Style, }, @@ -145,7 +145,7 @@ mod imp { let no_color = env::var("NO_COLOR"); let clicolor_force = env::var("CLICOLOR_FORCE"); let clicolor = env::var("CLICOLOR"); - set_color_mode(no_color, clicolor_force, clicolor) + get_color_mode(no_color, clicolor_force, clicolor) }; match COLOR_MODE.get_or_init(|| color_mode_init) { ColorMode::Auto => { @@ -166,7 +166,7 @@ mod imp { let no_color = env::var("NO_COLOR"); let clicolor_force = env::var("CLICOLOR_FORCE"); let clicolor = env::var("CLICOLOR"); - set_color_mode(no_color, clicolor_force, clicolor) + get_color_mode(no_color, clicolor_force, clicolor) }; match COLOR_MODE.get_or_init(|| color_mode_init) { ColorMode::Auto => { @@ -252,7 +252,7 @@ mod imp { use crate::{ encode::{ self, - writer::console::{set_color_mode, ColorMode, COLOR_MODE}, + writer::console::{get_color_mode, ColorMode, COLOR_MODE}, Color, Style, }, priv_io::{StdWriter, StdWriterLock}, @@ -352,7 +352,7 @@ mod imp { let no_color = env::var("NO_COLOR"); let clicolor_force = env::var("CLICOLOR_FORCE"); let clicolor = env::var("CLICOLOR"); - set_color_mode(no_color, clicolor_force, clicolor) + get_color_mode(no_color, clicolor_force, clicolor) }; match COLOR_MODE.get_or_init(|| color_mode_init) { ColorMode::Auto | ColorMode::Always => Some(writer), @@ -385,7 +385,7 @@ mod imp { let no_color = env::var("NO_COLOR"); let clicolor_force = env::var("CLICOLOR_FORCE"); let clicolor = env::var("CLICOLOR"); - set_color_mode(no_color, clicolor_force, clicolor) + get_color_mode(no_color, clicolor_force, clicolor) }; match COLOR_MODE.get_or_init(|| color_mode_init) { ColorMode::Auto | ColorMode::Always => Some(writer), @@ -478,12 +478,12 @@ mod test { w.write(b"normal ").unwrap(); w.set_style( - Style::new() - .text(Color::Red) - .background(Color::Blue) - .intense(true), - ) - .unwrap(); + Style::new() + .text(Color::Red) + .background(Color::Blue) + .intense(true), + ) + .unwrap(); w.write_all(b"styled").unwrap(); w.set_style(&Style::new().text(Color::Green).intense(false)) .unwrap(); @@ -501,7 +501,7 @@ mod test { let color_mode: OnceCell = OnceCell::new(); assert_eq!( - color_mode.get_or_init(|| set_color_mode(no_color, clicolor_force, clicolor)), + color_mode.get_or_init(|| get_color_mode(no_color, clicolor_force, clicolor)), &ColorMode::Auto ); } @@ -515,7 +515,7 @@ mod test { let mut color_mode: OnceCell = OnceCell::new(); assert_eq!( - color_mode.get_or_init(|| set_color_mode(no_color, clicolor_force, clicolor)), + color_mode.get_or_init(|| get_color_mode(no_color, clicolor_force, clicolor)), &ColorMode::Never ); @@ -525,7 +525,7 @@ mod test { let _ = color_mode.take(); // Clear the owned value assert_eq!( - color_mode.get_or_init(|| set_color_mode(no_color, clicolor_force, clicolor)), + color_mode.get_or_init(|| get_color_mode(no_color, clicolor_force, clicolor)), &ColorMode::Never ); } @@ -539,7 +539,7 @@ mod test { let mut color_mode: OnceCell = OnceCell::new(); assert_eq!( - color_mode.get_or_init(|| set_color_mode(no_color, clicolor_force, clicolor)), + color_mode.get_or_init(|| get_color_mode(no_color, clicolor_force, clicolor)), &ColorMode::Always ); @@ -552,7 +552,7 @@ mod test { let _ = color_mode.take(); // Clear the owned value assert_eq!( - color_mode.get_or_init(|| set_color_mode(no_color, clicolor_force, clicolor)), + color_mode.get_or_init(|| get_color_mode(no_color, clicolor_force, clicolor)), &ColorMode::Always ); @@ -562,7 +562,7 @@ mod test { let _ = color_mode.take(); // Clear the owned value assert_eq!( - color_mode.get_or_init(|| set_color_mode(no_color, clicolor_force, clicolor)), + color_mode.get_or_init(|| get_color_mode(no_color, clicolor_force, clicolor)), &ColorMode::Always ); } @@ -576,7 +576,7 @@ mod test { let mut color_mode: OnceCell = OnceCell::new(); assert_eq!( - color_mode.get_or_init(|| set_color_mode(no_color, clicolor_force, clicolor)), + color_mode.get_or_init(|| get_color_mode(no_color, clicolor_force, clicolor)), &ColorMode::Auto ); @@ -586,7 +586,7 @@ mod test { let _ = color_mode.take(); // Clear the owned value assert_eq!( - color_mode.get_or_init(|| set_color_mode(no_color, clicolor_force, clicolor)), + color_mode.get_or_init(|| get_color_mode(no_color, clicolor_force, clicolor)), &ColorMode::Never ); @@ -597,7 +597,7 @@ mod test { let _ = color_mode.take(); // Clear the owned value assert_eq!( - color_mode.get_or_init(|| set_color_mode(no_color, clicolor_force, clicolor)), + color_mode.get_or_init(|| get_color_mode(no_color, clicolor_force, clicolor)), &ColorMode::Auto ); } diff --git a/src/lib.rs b/src/lib.rs index a80f390b..0079b623 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -177,7 +177,7 @@ //! For more examples see the [examples](https://github.com/estk/log4rs/tree/main/examples). //! -#![allow(where_clauses_object_safety, clippy::manual_non_exhaustive)] +#![allow(clippy::manual_non_exhaustive)] #![warn(missing_docs)] use std::{