File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 22
33// FIXME (#13400): this is only a tiny fraction of the Windows console api
44
5- extern crate libc;
6-
75use std:: io;
86use std:: io:: prelude:: * ;
97
@@ -122,12 +120,17 @@ impl<T: Write + Send + 'static> WinConsole<T> {
122120
123121 /// Returns `None` whenever the terminal cannot be created for some reason.
124122 pub fn new ( out : T ) -> io:: Result < WinConsole < T > > {
123+ use std:: mem:: MaybeUninit ;
124+
125125 let fg;
126126 let bg;
127127 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 ( ) ;
131134 fg = bits_to_color ( buffer_info. wAttributes ) ;
132135 bg = bits_to_color ( buffer_info. wAttributes >> 4 ) ;
133136 } else {
You can’t perform that action at this time.
0 commit comments