mirror of
https://github.com/nushell/nushell
synced 2024-11-10 15:14:14 +00:00
Merge pull request #520 from est31/remove_try_trait
Remove try_trait feature use
This commit is contained in:
commit
4576570275
4 changed files with 8 additions and 52 deletions
31
src/cli.rs
31
src/cli.rs
|
@ -325,31 +325,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()),
|
||||
|
@ -366,8 +341,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(_)) => {}
|
||||
|
|
|
@ -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)),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue