diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-07-12 00:42:47 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-07-12 00:42:47 -0400 |
commit | 9db947a3f01a3138a4d86eae04cf1aa5fcca6010 (patch) | |
tree | dbc6becdef4c7cb7da00feae6cf64853ff7a0c44 | |
parent | dddc1a724a2f13676688e45315f3f6360d1e6113 (diff) | |
download | nbsh-old-9db947a3f01a3138a4d86eae04cf1aa5fcca6010.tar.gz nbsh-old-9db947a3f01a3138a4d86eae04cf1aa5fcca6010.zip |
simplify
-rw-r--r-- | src/tui.rs | 14 |
1 files changed, 4 insertions, 10 deletions
@@ -24,12 +24,10 @@ pub enum Error { pub type Result<T> = std::result::Result<T, Error>; pub fn tui() { - match Tui::new() { - Ok(state) => tokio::run(state), - Err(e) => eprintln!("failed to create state: {}", e), - } + tokio::run(Tui::new()); } +#[derive(Default)] pub struct Tui { idx: usize, readline: Option<crate::readline::Readline>, @@ -37,12 +35,8 @@ pub struct Tui { } impl Tui { - pub fn new() -> Result<Self> { - Ok(Self { - idx: 0, - readline: Some(Self::read()?), - commands: std::collections::HashMap::new(), - }) + pub fn new() -> Self { + Self::default() } fn read() -> Result<crate::readline::Readline> { |