aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/state.rs23
-rw-r--r--src/tui.rs9
2 files changed, 20 insertions, 12 deletions
diff --git a/src/state.rs b/src/state.rs
index b9707c0..f6c8a78 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -104,13 +104,8 @@ impl State {
eprint!("command exited: {}\r\n", status);
Ok(())
}
-}
-
-impl futures::future::Future for State {
- type Item = ();
- type Error = Error;
- fn poll(&mut self) -> futures::Poll<Self::Item, Self::Error> {
+ fn poll_with_errors(&mut self) -> futures::Poll<(), Error> {
loop {
let mut did_work = false;
@@ -175,6 +170,22 @@ impl futures::future::Future for State {
}
}
+impl futures::future::Future for State {
+ type Item = ();
+ type Error = ();
+
+ fn poll(&mut self) -> futures::Poll<Self::Item, Self::Error> {
+ loop {
+ match self.poll_with_errors() {
+ Ok(a) => return Ok(a),
+ Err(e) => {
+ eprint!("error polling state: {}\r\n", e);
+ }
+ }
+ }
+ }
+}
+
struct Command {
future: crate::eval::Eval,
res: futures::sync::oneshot::Sender<()>,
diff --git a/src/tui.rs b/src/tui.rs
index b7af752..6708340 100644
--- a/src/tui.rs
+++ b/src/tui.rs
@@ -11,9 +11,6 @@ pub enum Error {
#[snafu(display("error during eval: {}", source))]
Eval { source: crate::eval::Error },
- #[snafu(display("error during print: {}", source))]
- Print { source: crate::state::Error },
-
#[snafu(display("error during sending: {}", source))]
Sending {
source: futures::sync::mpsc::SendError<crate::state::StateEvent>,
@@ -29,9 +26,9 @@ pub fn tui() {
tokio::run(futures::lazy(|| {
let (w, r) = futures::sync::mpsc::channel(0);
- tokio::spawn(crate::state::State::new(r).map_err(|e| {
- error(&Error::Print { source: e });
- }));
+ tokio::spawn(
+ crate::state::State::new(r).map_err(|()| unreachable!()),
+ );
futures::future::loop_fn(0, move |idx| {
let w = w.clone();