refactor(editor): use std Result

It is simpler to keep the `anyhow` bits in the main exec loop
This commit is contained in:
Harsh Shandilya 2022-08-07 17:29:41 +05:30
parent c54d8f77ef
commit f8a516fb4b
No known key found for this signature in database
GPG Key ID: 366D7BBAD1031E80

View File

@ -1,5 +1,5 @@
use anyhow::Result;
use std::io::{self, stdout};
use std::result::Result;
use termion::{event::Key, input::TermRead, raw::IntoRawMode};
#[derive(Default)]
@ -20,7 +20,7 @@ impl Editor {
}
}
fn process_keypress(&mut self) -> Result<()> {
fn process_keypress(&mut self) -> Result<(), io::Error> {
let pressed_key = read_key()?;
match pressed_key {
Key::Ctrl('q') => self.should_quit = true,
@ -30,7 +30,7 @@ impl Editor {
}
}
fn read_key() -> std::result::Result<Key, std::io::Error> {
fn read_key() -> Result<Key, io::Error> {
loop {
if let Some(key) = io::stdin().lock().keys().next() {
return key;