Remove try_trait feature use

This commit is contained in:
est31 2019-08-29 03:12:10 +02:00
parent 3e72c3eca9
commit 012d8f3d6f
4 changed files with 8 additions and 52 deletions

View File

@ -330,31 +330,6 @@ enum LineResult {
FatalError(String, ShellError),
}
impl std::ops::Try for LineResult {
type Ok = Option<String>;
type Error = (String, ShellError);
fn into_result(self) -> Result<Option<String>, (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<String>) -> Self {
match v {
None => LineResult::Break,
Some(v) => LineResult::Success(v),
}
}
}
async fn process_line(readline: Result<String, ReadlineError>, 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<String, ReadlineError>, 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(_)) => {}

View File

@ -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, &registry, &raw_args.shell_manager, nothing)?
.into()
// let out = match command.run(&call_info, &registry, &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, &registry, &raw_args.shell_manager, nothing) {
Ok(o) => o,
Err(e) => OutputStream::one(Err(e)),
}
}
}
}

View File

@ -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)]

View File

@ -84,22 +84,6 @@ impl OutputStream {
}
}
impl std::ops::Try for OutputStream {
type Ok = OutputStream;
type Error = ShellError;
fn into_result(self) -> Result<Self::Ok, Self::Error> {
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;