Skip to content

Commit

Permalink
Rollup merge of #103340 - RalfJung:winconsole, r=thomcc
Browse files Browse the repository at this point in the history
WinConsole::new is not actually fallible

I just noticed this while reading the code for other reasons.
r? ``@thomcc``
  • Loading branch information
matthiaskrgr authored Oct 21, 2022
2 parents 7ee0aea + 3ff0a33 commit b21eb5e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion library/test/src/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub(crate) fn stdout() -> Option<Box<StdoutTerminal>> {
pub(crate) fn stdout() -> Option<Box<StdoutTerminal>> {
TerminfoTerminal::new(io::stdout())
.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
Expand Down
7 changes: 3 additions & 4 deletions library/test/src/term/win.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) -> io::Result<WinConsole<T>> {
pub(crate) fn new(out: T) -> WinConsole<T> {
use std::mem::MaybeUninit;

let fg;
Expand All @@ -132,13 +131,13 @@ impl<T: Write + Send + 'static> WinConsole<T> {
bg = color::BLACK;
}
}
Ok(WinConsole {
WinConsole {
buf: out,
def_foreground: fg,
def_background: bg,
foreground: fg,
background: bg,
})
}
}
}

Expand Down

0 comments on commit b21eb5e

Please sign in to comment.