From 012d8f3d6f9d45847418a52b4adc393c61a2ba7e Mon Sep 17 00:00:00 2001 From: est31 Date: Thu, 29 Aug 2019 03:12:10 +0200 Subject: [PATCH] Remove try_trait feature use --- src/cli.rs | 31 ++++--------------------------- src/commands/command.rs | 12 ++++-------- src/lib.rs | 1 - src/stream.rs | 16 ---------------- 4 files changed, 8 insertions(+), 52 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index c3a2995744..99ba9cd8d6 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -330,31 +330,6 @@ enum LineResult { FatalError(String, ShellError), } -impl std::ops::Try for LineResult { - type Ok = Option; - type Error = (String, ShellError); - - fn into_result(self) -> Result, (String, ShellError)> { - match self { - LineResult::Success(s) => Ok(Some(s)), - LineResult::Error(string, err) => Err((string, err)), - LineResult::Break => Ok(None), - LineResult::CtrlC => Ok(None), - LineResult::FatalError(string, err) => Err((string, err)), - } - } - fn from_error(v: (String, ShellError)) -> Self { - LineResult::Error(v.0, v.1) - } - - fn from_ok(v: Option) -> Self { - match v { - None => LineResult::Break, - Some(v) => LineResult::Success(v), - } - } -} - async fn process_line(readline: Result, ctx: &mut Context) -> LineResult { match &readline { Ok(line) if line.trim() == "" => LineResult::Success(line.clone()), @@ -371,8 +346,10 @@ async fn process_line(readline: Result, ctx: &mut Context debug!("=== Parsed ==="); debug!("{:#?}", result); - let mut pipeline = classify_pipeline(&result, ctx, &Text::from(line)) - .map_err(|err| (line.clone(), err))?; + let mut pipeline = match classify_pipeline(&result, ctx, &Text::from(line)) { + Ok(pipeline) => pipeline, + Err(err) => return LineResult::Error(line.clone(), err), + }; match pipeline.commands.last() { Some(ClassifiedCommand::External(_)) => {} diff --git a/src/commands/command.rs b/src/commands/command.rs index b11c0a5beb..9c8e786a1a 100644 --- a/src/commands/command.rs +++ b/src/commands/command.rs @@ -596,14 +596,10 @@ impl Command { .unwrap(); // We don't have an $it or block, so just execute what we have - command - .run(&call_info, ®istry, &raw_args.shell_manager, nothing)? - .into() - // let out = match command.run(&call_info, ®istry, &raw_args.shell_manager, nothing) { - // Ok(o) => o, - // Err(e) => VecDeque::from(vec![ReturnValue::Err(e)]), - // }; - // Ok(out.to_output_stream()) + match command.run(&call_info, ®istry, &raw_args.shell_manager, nothing) { + Ok(o) => o, + Err(e) => OutputStream::one(Err(e)), + } } } } diff --git a/src/lib.rs b/src/lib.rs index 74ad22a68e..f195fba648 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,6 @@ #![feature(crate_visibility_modifier)] #![feature(in_band_lifetimes)] #![feature(generators)] -#![feature(try_trait)] #![feature(bind_by_move_pattern_guards)] #![feature(specialization)] #![feature(proc_macro_hygiene)] diff --git a/src/stream.rs b/src/stream.rs index 929f1fdc28..5b73172bfc 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -84,22 +84,6 @@ impl OutputStream { } } -impl std::ops::Try for OutputStream { - type Ok = OutputStream; - type Error = ShellError; - fn into_result(self) -> Result { - Ok(self) - } - - fn from_error(v: Self::Error) -> Self { - OutputStream::one(Err(v)) - } - - fn from_ok(v: Self::Ok) -> Self { - v - } -} - impl Stream for OutputStream { type Item = ReturnValue;