WinConsole::new is not actually fallible
This commit is contained in:
parent
b1ab3b738a
commit
3ff0a33a83
@ -39,7 +39,7 @@ pub(crate) fn stdout() -> Option<Box<StdoutTerminal>> {
|
|||||||
pub(crate) fn stdout() -> Option<Box<StdoutTerminal>> {
|
pub(crate) fn stdout() -> Option<Box<StdoutTerminal>> {
|
||||||
TerminfoTerminal::new(io::stdout())
|
TerminfoTerminal::new(io::stdout())
|
||||||
.map(|t| Box::new(t) as Box<StdoutTerminal>)
|
.map(|t| Box::new(t) as Box<StdoutTerminal>)
|
||||||
.or_else(|| WinConsole::new(io::stdout()).ok().map(|t| Box::new(t) as Box<StdoutTerminal>))
|
.or_else(|| Some(Box::new(WinConsole::new(io::stdout())) as Box<StdoutTerminal>))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Terminal color definitions
|
/// Terminal color definitions
|
||||||
|
@ -113,8 +113,7 @@ impl<T: Write + Send + 'static> WinConsole<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `None` whenever the terminal cannot be created for some reason.
|
pub(crate) fn new(out: T) -> WinConsole<T> {
|
||||||
pub(crate) fn new(out: T) -> io::Result<WinConsole<T>> {
|
|
||||||
use std::mem::MaybeUninit;
|
use std::mem::MaybeUninit;
|
||||||
|
|
||||||
let fg;
|
let fg;
|
||||||
@ -132,13 +131,13 @@ impl<T: Write + Send + 'static> WinConsole<T> {
|
|||||||
bg = color::BLACK;
|
bg = color::BLACK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(WinConsole {
|
WinConsole {
|
||||||
buf: out,
|
buf: out,
|
||||||
def_foreground: fg,
|
def_foreground: fg,
|
||||||
def_background: bg,
|
def_background: bg,
|
||||||
foreground: fg,
|
foreground: fg,
|
||||||
background: bg,
|
background: bg,
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user