Skip to content

Commit 4fa21ad

Browse files
committed
Simplify windows read_single_key()
1 parent 456eb78 commit 4fa21ad

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/windows_term/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,15 +410,13 @@ pub(crate) fn read_secure() -> io::Result<String> {
410410

411411
pub(crate) fn read_single_key(ctrlc_key: bool) -> io::Result<Key> {
412412
let key_event = {
413-
let _guard = if ctrlc_key {
413+
let _guard = ctrlc_key.then(|| {
414414
ConsoleModeGuard::set(
415415
unsafe { GetStdHandle(STD_INPUT_HANDLE) },
416416
ENABLE_PROCESSED_INPUT,
417417
false,
418418
)
419-
} else {
420-
None
421-
};
419+
});
422420
read_key_event()?
423421
};
424422

0 commit comments

Comments
 (0)