I have the following code to read user input keys from terminal using termion
use std::io::{stdin, stdout};
use termion::event::Key;
fn main() {
let mut stdout = stdout().into_raw_mode().unwrap();
let stdin = stdin();
let char_from_config = 'e';
for c in stdin.keys() {
match c.unwrap() {
Key::Char('q') => {
break;
}
Key::Char('h') => {
// do something
}
Key::Char('l') => {
// do something else
}
_ => {}
}
stdout.flush().unwrap();
}
}
What I would want to do is to read not just Key::Char('q') but some other dynamic character value, which I collect from somewhere else, like Key::Char(char_from_config), but it doesn't work for some reason.
Is there a way to paste a variable containing char instead of an actual 'char' to match arms ?