@@ -8,20 +8,16 @@ type StdioColorInnerResult = Result<(anstyle::AnsiColor, anstyle::AnsiColor), in
8
8
9
9
/// Cached [`get_colors`] call for [`std::io::stdout`]
10
10
pub fn stdout_initial_colors ( ) -> StdioColorResult {
11
- static INITIAL : std:: sync:: OnceLock < StdioColorInnerResult > = std:: sync:: OnceLock :: new ( ) ;
12
- INITIAL
13
- . get_or_init ( || get_colors_ ( & std:: io:: stdout ( ) ) )
14
- . clone ( )
15
- . map_err ( Into :: into)
11
+ static INITIAL : once_cell:: sync:: OnceCell < StdioColorInnerResult > =
12
+ once_cell:: sync:: OnceCell :: new ( ) ;
13
+ ( * INITIAL . get_or_init ( || get_colors_ ( & std:: io:: stdout ( ) ) ) ) . map_err ( Into :: into)
16
14
}
17
15
18
16
/// Cached [`get_colors`] call for [`std::io::stderr`]
19
17
pub fn stderr_initial_colors ( ) -> StdioColorResult {
20
- static INITIAL : std:: sync:: OnceLock < StdioColorInnerResult > = std:: sync:: OnceLock :: new ( ) ;
21
- INITIAL
22
- . get_or_init ( || get_colors_ ( & std:: io:: stderr ( ) ) )
23
- . clone ( )
24
- . map_err ( Into :: into)
18
+ static INITIAL : once_cell:: sync:: OnceCell < StdioColorInnerResult > =
19
+ once_cell:: sync:: OnceCell :: new ( ) ;
20
+ ( * INITIAL . get_or_init ( || get_colors_ ( & std:: io:: stderr ( ) ) ) ) . map_err ( Into :: into)
25
21
}
26
22
27
23
/// Apply colors to future writes
@@ -129,7 +125,7 @@ mod inner {
129
125
handle : RawHandle ,
130
126
) -> Result < CONSOLE_SCREEN_BUFFER_INFO , IoError > {
131
127
unsafe {
132
- let handle: HANDLE = std :: mem :: transmute ( handle) ;
128
+ let handle: HANDLE = handle as HANDLE ;
133
129
if handle. is_null ( ) {
134
130
return Err ( IoError :: BrokenPipe ) ;
135
131
}
@@ -150,7 +146,7 @@ mod inner {
150
146
attributes : CONSOLE_CHARACTER_ATTRIBUTES ,
151
147
) -> Result < ( ) , IoError > {
152
148
unsafe {
153
- let handle: HANDLE = std :: mem :: transmute ( handle) ;
149
+ let handle: HANDLE = handle as HANDLE ;
154
150
if handle. is_null ( ) {
155
151
return Err ( IoError :: BrokenPipe ) ;
156
152
}
@@ -258,7 +254,7 @@ mod inner {
258
254
for expected in COLORS {
259
255
let nibble = to_nibble ( expected) ;
260
256
let actual = from_nibble ( nibble) ;
261
- assert_eq ! ( expected, actual, "Intermediate: {}" , nibble ) ;
257
+ assert_eq ! ( expected, actual, "Intermediate: {nibble}" ) ;
262
258
}
263
259
}
264
260
}
0 commit comments