refact(ui): infallible conversion for u8 to char
This commit is contained in:
@@ -33,13 +33,11 @@ pub fn read_single_char_from_terminal() -> Result<char> {
|
|||||||
new_termios.c_cc[VTIME] = 0;
|
new_termios.c_cc[VTIME] = 0;
|
||||||
tcsetattr(fd, TCSANOW, &new_termios).context("setting terminal mode")?;
|
tcsetattr(fd, TCSANOW, &new_termios).context("setting terminal mode")?;
|
||||||
|
|
||||||
let mut input = [0u8; 1];
|
let mut input_buffer = [0u8; 1];
|
||||||
io::stdin()
|
io::stdin()
|
||||||
.read_exact(&mut input[..])
|
.read_exact(&mut input_buffer[..])
|
||||||
.context("reading one byte from stdin")?;
|
.context("reading one byte from stdin")?;
|
||||||
let result: char = input[0]
|
let result: char = input_buffer[0].into();
|
||||||
.try_into()
|
|
||||||
.context("reading a single byte from stdin")?;
|
|
||||||
|
|
||||||
// stdin is not echoed automatically in this terminal mode
|
// stdin is not echoed automatically in this terminal mode
|
||||||
println!("{result}");
|
println!("{result}");
|
||||||
|
|||||||
Reference in New Issue
Block a user