File tree 1 file changed +8
-5
lines changed
1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 2
2
3
3
// FIXME (#13400): this is only a tiny fraction of the Windows console api
4
4
5
- extern crate libc;
6
-
7
5
use std:: io;
8
6
use std:: io:: prelude:: * ;
9
7
@@ -122,12 +120,17 @@ impl<T: Write + Send + 'static> WinConsole<T> {
122
120
123
121
/// Returns `None` whenever the terminal cannot be created for some reason.
124
122
pub fn new ( out : T ) -> io:: Result < WinConsole < T > > {
123
+ use std:: mem:: MaybeUninit ;
124
+
125
125
let fg;
126
126
let bg;
127
127
unsafe {
128
- #[ allow( deprecated) ]
129
- let mut buffer_info = :: std:: mem:: uninitialized ( ) ;
130
- if GetConsoleScreenBufferInfo ( GetStdHandle ( -11i32 as DWORD ) , & mut buffer_info) != 0 {
128
+ let mut buffer_info = MaybeUninit :: < CONSOLE_SCREEN_BUFFER_INFO > :: uninit ( ) ;
129
+ if GetConsoleScreenBufferInfo (
130
+ GetStdHandle ( -11i32 as DWORD ) ,
131
+ buffer_info. as_mut_ptr ( )
132
+ ) != 0 {
133
+ let buffer_info = buffer_info. assume_init ( ) ;
131
134
fg = bits_to_color ( buffer_info. wAttributes ) ;
132
135
bg = bits_to_color ( buffer_info. wAttributes >> 4 ) ;
133
136
} else {
You can’t perform that action at this time.
0 commit comments