From 5481db40799855051754456a38866de64696ac00 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Fri, 12 Feb 2021 23:13:14 +1300 Subject: [PATCH] Fix latest clippy warnings (#3049) --- Cargo.toml | 1 + crates/nu-cli/src/cli.rs | 18 ++++++------ .../src/env/directory_specific_environment.rs | 6 ++-- crates/nu-cli/src/prelude.rs | 2 ++ crates/nu-cli/src/types/deduction.rs | 8 +++--- crates/nu-command/src/commands/ansi.rs | 2 +- crates/nu-command/src/commands/autoenv.rs | 4 +-- .../src/commands/autoview/command.rs | 2 +- crates/nu-command/src/commands/cal.rs | 2 +- crates/nu-command/src/commands/cd.rs | 2 +- crates/nu-command/src/commands/char_.rs | 2 +- crates/nu-command/src/commands/chart.rs | 2 +- crates/nu-command/src/commands/clip.rs | 2 +- crates/nu-command/src/commands/compact.rs | 2 +- crates/nu-command/src/commands/count.rs | 2 +- crates/nu-command/src/commands/cp.rs | 2 +- .../nu-command/src/commands/date/command.rs | 2 +- crates/nu-command/src/commands/date/format.rs | 2 +- .../src/commands/date/list_timezone.rs | 2 +- crates/nu-command/src/commands/date/now.rs | 2 +- .../nu-command/src/commands/date/to_table.rs | 2 +- .../src/commands/date/to_timezone.rs | 2 +- crates/nu-command/src/commands/date/utc.rs | 2 +- crates/nu-command/src/commands/debug.rs | 2 +- crates/nu-command/src/commands/default.rs | 2 +- crates/nu-command/src/commands/describe.rs | 2 +- crates/nu-command/src/commands/do_.rs | 2 +- crates/nu-command/src/commands/drop.rs | 2 +- crates/nu-command/src/commands/du.rs | 2 +- .../nu-command/src/commands/each/command.rs | 2 +- crates/nu-command/src/commands/each/group.rs | 2 +- crates/nu-command/src/commands/each/window.rs | 2 +- crates/nu-command/src/commands/echo.rs | 2 +- crates/nu-command/src/commands/enter.rs | 2 +- crates/nu-command/src/commands/every.rs | 2 +- crates/nu-command/src/commands/exit.rs | 2 +- crates/nu-command/src/commands/first.rs | 2 +- crates/nu-command/src/commands/flatten.rs | 12 ++++---- .../nu-command/src/commands/format/command.rs | 2 +- .../src/commands/format/format_filesize.rs | 2 +- crates/nu-command/src/commands/from.rs | 2 +- crates/nu-command/src/commands/from_csv.rs | 2 +- crates/nu-command/src/commands/from_eml.rs | 2 +- crates/nu-command/src/commands/from_ics.rs | 2 +- crates/nu-command/src/commands/from_ini.rs | 2 +- crates/nu-command/src/commands/from_json.rs | 2 +- crates/nu-command/src/commands/from_ods.rs | 2 +- crates/nu-command/src/commands/from_ssv.rs | 28 ++++++------------- crates/nu-command/src/commands/from_toml.rs | 2 +- crates/nu-command/src/commands/from_tsv.rs | 2 +- crates/nu-command/src/commands/from_url.rs | 2 +- crates/nu-command/src/commands/from_vcf.rs | 2 +- crates/nu-command/src/commands/from_xlsx.rs | 2 +- crates/nu-command/src/commands/from_xml.rs | 2 +- crates/nu-command/src/commands/from_yaml.rs | 4 +-- .../nu-command/src/commands/group_by_date.rs | 2 +- .../nu-command/src/commands/hash_/command.rs | 2 +- crates/nu-command/src/commands/headers.rs | 2 +- crates/nu-command/src/commands/help.rs | 2 +- crates/nu-command/src/commands/histogram.rs | 2 +- crates/nu-command/src/commands/history.rs | 2 +- crates/nu-command/src/commands/if_.rs | 2 +- crates/nu-command/src/commands/into_int.rs | 2 +- .../nu-command/src/commands/keep/command.rs | 2 +- crates/nu-command/src/commands/keep/until.rs | 2 +- crates/nu-command/src/commands/keep/while_.rs | 2 +- crates/nu-command/src/commands/kill.rs | 2 +- crates/nu-command/src/commands/last.rs | 2 +- crates/nu-command/src/commands/lines.rs | 2 +- crates/nu-command/src/commands/ls.rs | 2 +- crates/nu-command/src/commands/math/abs.rs | 2 +- crates/nu-command/src/commands/math/avg.rs | 2 +- crates/nu-command/src/commands/math/ceil.rs | 2 +- .../nu-command/src/commands/math/command.rs | 2 +- crates/nu-command/src/commands/math/eval.rs | 2 +- crates/nu-command/src/commands/math/floor.rs | 2 +- crates/nu-command/src/commands/math/max.rs | 2 +- crates/nu-command/src/commands/math/median.rs | 2 +- crates/nu-command/src/commands/math/min.rs | 2 +- crates/nu-command/src/commands/math/mode.rs | 2 +- .../nu-command/src/commands/math/product.rs | 2 +- crates/nu-command/src/commands/math/round.rs | 2 +- crates/nu-command/src/commands/math/stddev.rs | 2 +- crates/nu-command/src/commands/math/sum.rs | 2 +- .../nu-command/src/commands/math/variance.rs | 2 +- crates/nu-command/src/commands/merge.rs | 2 +- crates/nu-command/src/commands/mkdir.rs | 2 +- crates/nu-command/src/commands/move_/mv.rs | 2 +- crates/nu-command/src/commands/next.rs | 8 +++--- crates/nu-command/src/commands/nth.rs | 2 +- crates/nu-command/src/commands/nu/plugin.rs | 2 +- crates/nu-command/src/commands/open.rs | 10 +++---- .../nu-command/src/commands/parse/command.rs | 2 +- .../nu-command/src/commands/path/basename.rs | 2 +- .../nu-command/src/commands/path/command.rs | 2 +- .../nu-command/src/commands/path/dirname.rs | 2 +- crates/nu-command/src/commands/path/exists.rs | 2 +- crates/nu-command/src/commands/path/expand.rs | 2 +- .../nu-command/src/commands/path/extension.rs | 2 +- .../nu-command/src/commands/path/filestem.rs | 2 +- crates/nu-command/src/commands/path/type.rs | 2 +- crates/nu-command/src/commands/pivot.rs | 2 +- crates/nu-command/src/commands/prepend.rs | 2 +- crates/nu-command/src/commands/prev.rs | 8 +++--- crates/nu-command/src/commands/pwd.rs | 2 +- crates/nu-command/src/commands/random/bool.rs | 2 +- .../nu-command/src/commands/random/chars.rs | 2 +- .../nu-command/src/commands/random/decimal.rs | 2 +- crates/nu-command/src/commands/random/dice.rs | 2 +- .../nu-command/src/commands/random/integer.rs | 2 +- crates/nu-command/src/commands/random/uuid.rs | 2 +- crates/nu-command/src/commands/range.rs | 2 +- crates/nu-command/src/commands/reduce.rs | 2 +- crates/nu-command/src/commands/reject.rs | 2 +- crates/nu-command/src/commands/rename.rs | 2 +- crates/nu-command/src/commands/reverse.rs | 2 +- crates/nu-command/src/commands/rm.rs | 2 +- crates/nu-command/src/commands/save.rs | 10 +++---- crates/nu-command/src/commands/seq.rs | 10 +++---- crates/nu-command/src/commands/seq_dates.rs | 2 +- crates/nu-command/src/commands/shells.rs | 8 +++--- crates/nu-command/src/commands/shuffle.rs | 2 +- crates/nu-command/src/commands/size.rs | 10 +++---- .../nu-command/src/commands/skip/command.rs | 2 +- crates/nu-command/src/commands/skip/until.rs | 2 +- crates/nu-command/src/commands/skip/while_.rs | 2 +- crates/nu-command/src/commands/sleep.rs | 2 +- crates/nu-command/src/commands/sort_by.rs | 2 +- crates/nu-command/src/commands/split/chars.rs | 2 +- .../nu-command/src/commands/split/column.rs | 2 +- .../nu-command/src/commands/split/command.rs | 2 +- crates/nu-command/src/commands/split/row.rs | 2 +- crates/nu-command/src/commands/split_by.rs | 2 +- .../src/commands/str_/capitalize.rs | 2 +- .../src/commands/str_/case/camel_case.rs | 2 +- .../src/commands/str_/case/kebab_case.rs | 2 +- .../src/commands/str_/case/pascal_case.rs | 2 +- .../str_/case/screaming_snake_case.rs | 2 +- .../src/commands/str_/case/snake_case.rs | 2 +- .../nu-command/src/commands/str_/collect.rs | 2 +- .../nu-command/src/commands/str_/command.rs | 2 +- .../nu-command/src/commands/str_/contains.rs | 6 ++-- .../nu-command/src/commands/str_/downcase.rs | 2 +- .../nu-command/src/commands/str_/ends_with.rs | 2 +- .../src/commands/str_/find_replace.rs | 2 +- crates/nu-command/src/commands/str_/from.rs | 2 +- .../nu-command/src/commands/str_/index_of.rs | 2 +- crates/nu-command/src/commands/str_/length.rs | 2 +- crates/nu-command/src/commands/str_/lpad.rs | 2 +- .../nu-command/src/commands/str_/reverse.rs | 2 +- crates/nu-command/src/commands/str_/rpad.rs | 2 +- .../src/commands/str_/starts_with.rs | 2 +- .../nu-command/src/commands/str_/substring.rs | 2 +- .../src/commands/str_/to_datetime.rs | 2 +- .../src/commands/str_/to_decimal.rs | 2 +- .../src/commands/str_/to_integer.rs | 2 +- .../nu-command/src/commands/str_/trim/mod.rs | 2 +- .../src/commands/str_/trim/trim_both_ends.rs | 2 +- .../src/commands/str_/trim/trim_left.rs | 2 +- .../src/commands/str_/trim/trim_right.rs | 2 +- crates/nu-command/src/commands/str_/upcase.rs | 2 +- .../nu-command/src/commands/table/command.rs | 2 +- crates/nu-command/src/commands/tags.rs | 11 ++++---- crates/nu-command/src/commands/to.rs | 2 +- crates/nu-command/src/commands/to_csv.rs | 2 +- crates/nu-command/src/commands/to_html.rs | 2 +- crates/nu-command/src/commands/to_json.rs | 2 +- crates/nu-command/src/commands/to_toml.rs | 2 +- crates/nu-command/src/commands/to_tsv.rs | 2 +- crates/nu-command/src/commands/to_url.rs | 2 +- crates/nu-command/src/commands/to_xml.rs | 2 +- crates/nu-command/src/commands/to_yaml.rs | 2 +- crates/nu-command/src/commands/touch.rs | 2 +- crates/nu-command/src/commands/uniq.rs | 2 +- .../nu-command/src/commands/url_/command.rs | 2 +- crates/nu-command/src/commands/url_/host.rs | 2 +- crates/nu-command/src/commands/url_/path.rs | 2 +- crates/nu-command/src/commands/url_/query.rs | 2 +- crates/nu-command/src/commands/url_/scheme.rs | 2 +- crates/nu-command/src/commands/version.rs | 6 ++-- crates/nu-command/src/commands/where_.rs | 2 +- crates/nu-command/src/commands/which_.rs | 2 +- crates/nu-command/src/commands/with_env.rs | 2 +- crates/nu-command/src/commands/wrap.rs | 2 +- crates/nu-command/src/prelude.rs | 2 ++ crates/nu-command/src/utils/arguments.rs | 2 +- crates/nu-data/src/base/shape.rs | 18 ++++++------ .../src/filesystem/filesystem_shell.rs | 6 ++-- crates/nu-engine/src/plugin/build_plugin.rs | 1 - crates/nu-engine/src/plugin/run_plugin.rs | 8 +++--- crates/nu-engine/src/shell/help_shell.rs | 6 ++-- crates/nu-engine/src/shell/mod.rs | 6 ++-- crates/nu-engine/src/shell/shell_manager.rs | 6 ++-- crates/nu-engine/src/shell/value_shell.rs | 4 +-- crates/nu-errors/src/lib.rs | 4 +-- crates/nu-json/src/de.rs | 2 +- crates/nu-json/src/value.rs | 2 +- crates/nu-parser/src/lex/token_group.rs | 6 ++-- crates/nu-parser/src/parse.rs | 3 +- crates/nu-parser/src/parse/def/primitives.rs | 11 +++----- crates/nu-protocol/src/hir.rs | 6 ++-- crates/nu-protocol/src/type_shape.rs | 18 ++++++------ crates/nu-protocol/src/value.rs | 6 ++-- .../nu-protocol/src/value/serde_bigdecimal.rs | 4 +-- crates/nu-protocol/src/value/serde_bigint.rs | 4 +-- crates/nu-source/src/pretty.rs | 12 ++++---- crates/nu-stream/src/input.rs | 1 + crates/nu-stream/src/prelude.rs | 1 + crates/nu_plugin_binaryview/src/binaryview.rs | 12 ++++---- .../nu_plugin_from_sqlite/src/from_sqlite.rs | 9 ++---- crates/nu_plugin_inc/src/inc.rs | 27 ++++++++---------- crates/nu_plugin_selector/src/nu/mod.rs | 2 +- crates/nu_plugin_selector/src/selector.rs | 20 ++++--------- 213 files changed, 334 insertions(+), 375 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dcb94594ce..356a57d49a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -151,6 +151,7 @@ xpath = ["nu_plugin_xpath"] codegen-units = 1 #Reduce parallel codegen units lto = true #Link Time Optimization opt-level = 'z' #Optimize for size +debug = true # Core plugins that ship with `cargo install nu` by default # Currently, Cargo limits us to installing only one binary diff --git a/crates/nu-cli/src/cli.rs b/crates/nu-cli/src/cli.rs index 991c8d1ab6..04b47813e8 100644 --- a/crates/nu-cli/src/cli.rs +++ b/crates/nu-cli/src/cli.rs @@ -48,16 +48,14 @@ pub fn search_paths() -> Vec { } if let Ok(config) = nu_data::config::config(Tag::unknown()) { - if let Some(plugin_dirs) = config.get("plugin_dirs") { - if let Value { - value: UntaggedValue::Table(pipelines), - .. - } = plugin_dirs - { - for pipeline in pipelines { - if let Ok(plugin_dir) = pipeline.as_string() { - search_paths.push(PathBuf::from(plugin_dir)); - } + if let Some(Value { + value: UntaggedValue::Table(pipelines), + .. + }) = config.get("plugin_dirs") + { + for pipeline in pipelines { + if let Ok(plugin_dir) = pipeline.as_string() { + search_paths.push(PathBuf::from(plugin_dir)); } } } diff --git a/crates/nu-cli/src/env/directory_specific_environment.rs b/crates/nu-cli/src/env/directory_specific_environment.rs index 32bda8a943..4a3deceaae 100644 --- a/crates/nu-cli/src/env/directory_specific_environment.rs +++ b/crates/nu-cli/src/env/directory_specific_environment.rs @@ -51,7 +51,7 @@ impl DirectorySpecificEnvironment { } } - fn toml_if_trusted(&mut self, nu_env_file: &PathBuf) -> Result { + fn toml_if_trusted(&mut self, nu_env_file: &Path) -> Result { let content = std::fs::read(&nu_env_file)?; if autoenv::file_is_trusted(&nu_env_file, &content)? { @@ -161,7 +161,7 @@ impl DirectorySpecificEnvironment { pub fn maybe_add_key( &mut self, seen_vars: &mut IndexSet, - dir: &PathBuf, + dir: &Path, key: &str, val: &str, ) { @@ -169,7 +169,7 @@ impl DirectorySpecificEnvironment { if !seen_vars.contains(key) { seen_vars.insert(key.to_string()); self.added_vars - .entry(dir.clone()) + .entry(PathBuf::from(dir)) .or_insert(IndexMap::new()) .insert(key.to_string(), var_os(key)); diff --git a/crates/nu-cli/src/prelude.rs b/crates/nu-cli/src/prelude.rs index d111a92994..50e8b5f86b 100644 --- a/crates/nu-cli/src/prelude.rs +++ b/crates/nu-cli/src/prelude.rs @@ -58,6 +58,7 @@ pub(crate) use nu_value_ext::ValueExt; #[allow(unused_imports)] pub(crate) use std::sync::atomic::Ordering; +#[allow(clippy::clippy::wrong_self_convention)] pub trait FromInputStream { fn from_input_stream(self) -> OutputStream; } @@ -73,6 +74,7 @@ where } } +#[allow(clippy::clippy::wrong_self_convention)] pub trait ToOutputStream { fn to_output_stream(self) -> OutputStream; } diff --git a/crates/nu-cli/src/types/deduction.rs b/crates/nu-cli/src/types/deduction.rs index 4928591100..3990324c82 100644 --- a/crates/nu-cli/src/types/deduction.rs +++ b/crates/nu-cli/src/types/deduction.rs @@ -211,7 +211,7 @@ fn get_result_shape_of( l_shape: SyntaxShape, op_expr: &SpannedExpression, r_shape: SyntaxShape, -) -> Result { +) -> SyntaxShape { let op = match op_expr.expr { Expression::Literal(Literal::Operator(op)) => op, _ => unreachable!("Passing anything but the op expr is invalid"), @@ -220,7 +220,7 @@ fn get_result_shape_of( //There is some code for that in the evaluator already. //One might reuse it. //For now we ignore this issue - Ok(match op { + match op { Operator::Equal | Operator::NotEqual | Operator::LessThan @@ -258,7 +258,7 @@ fn get_result_shape_of( } Operator::Modulo => SyntaxShape::Number, Operator::Pow => SyntaxShape::Number, - }) + } } fn get_shape_of_expr(expr: &SpannedExpression) -> Option { @@ -334,7 +334,7 @@ fn get_result_shape_of_math_expr( //match lhs, rhs match (shapes[0], shapes[1]) { (None, None) | (None, _) | (_, None) => Ok(None), - (Some(left), Some(right)) => get_result_shape_of(left, &bin.op, right).map(Some), + (Some(left), Some(right)) => Ok(Some(get_result_shape_of(left, &bin.op, right))), } } diff --git a/crates/nu-command/src/commands/ansi.rs b/crates/nu-command/src/commands/ansi.rs index 11405a2524..fa8ff24dfd 100644 --- a/crates/nu-command/src/commands/ansi.rs +++ b/crates/nu-command/src/commands/ansi.rs @@ -286,6 +286,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Ansi {})?) + test_examples(Ansi {}) } } diff --git a/crates/nu-command/src/commands/autoenv.rs b/crates/nu-command/src/commands/autoenv.rs index 35d3f67436..e14260a3bf 100644 --- a/crates/nu-command/src/commands/autoenv.rs +++ b/crates/nu-command/src/commands/autoenv.rs @@ -6,7 +6,7 @@ use serde::Deserialize; use serde::Serialize; use sha2::{Digest, Sha256}; use std::io::Read; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; pub struct Autoenv; #[derive(Deserialize, Serialize, Debug, Default)] @@ -20,7 +20,7 @@ impl Trusted { } } } -pub fn file_is_trusted(nu_env_file: &PathBuf, content: &[u8]) -> Result { +pub fn file_is_trusted(nu_env_file: &Path, content: &[u8]) -> Result { let contentdigest = Sha256::digest(&content).as_slice().to_vec(); let nufile = std::fs::canonicalize(nu_env_file)?; diff --git a/crates/nu-command/src/commands/autoview/command.rs b/crates/nu-command/src/commands/autoview/command.rs index 466414fecf..9c749ec0d7 100644 --- a/crates/nu-command/src/commands/autoview/command.rs +++ b/crates/nu-command/src/commands/autoview/command.rs @@ -316,6 +316,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Command {})?) + test_examples(Command {}) } } diff --git a/crates/nu-command/src/commands/cal.rs b/crates/nu-command/src/commands/cal.rs index 721f4e0d40..24d5e46e73 100644 --- a/crates/nu-command/src/commands/cal.rs +++ b/crates/nu-command/src/commands/cal.rs @@ -337,6 +337,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Cal {})?) + test_examples(Cal {}) } } diff --git a/crates/nu-command/src/commands/cd.rs b/crates/nu-command/src/commands/cd.rs index 727a3fa7d8..9ec72e1e6a 100644 --- a/crates/nu-command/src/commands/cd.rs +++ b/crates/nu-command/src/commands/cd.rs @@ -67,6 +67,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Cd {})?) + test_examples(Cd {}) } } diff --git a/crates/nu-command/src/commands/char_.rs b/crates/nu-command/src/commands/char_.rs index 023b26633c..6c5aa1e672 100644 --- a/crates/nu-command/src/commands/char_.rs +++ b/crates/nu-command/src/commands/char_.rs @@ -143,6 +143,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Char {})?) + test_examples(Char {}) } } diff --git a/crates/nu-command/src/commands/chart.rs b/crates/nu-command/src/commands/chart.rs index a8824d8d34..d5d697fd23 100644 --- a/crates/nu-command/src/commands/chart.rs +++ b/crates/nu-command/src/commands/chart.rs @@ -42,6 +42,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Chart {})?) + test_examples(Chart {}) } } diff --git a/crates/nu-command/src/commands/clip.rs b/crates/nu-command/src/commands/clip.rs index 2a132d5ec4..ac1f290ad2 100644 --- a/crates/nu-command/src/commands/clip.rs +++ b/crates/nu-command/src/commands/clip.rs @@ -101,6 +101,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Clip {})?) + test_examples(Clip {}) } } diff --git a/crates/nu-command/src/commands/compact.rs b/crates/nu-command/src/commands/compact.rs index afde2eb2bc..c75d21522e 100644 --- a/crates/nu-command/src/commands/compact.rs +++ b/crates/nu-command/src/commands/compact.rs @@ -81,6 +81,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Compact {})?) + test_examples(Compact {}) } } diff --git a/crates/nu-command/src/commands/count.rs b/crates/nu-command/src/commands/count.rs index b3a0c6d6ca..50ae8ddd9d 100644 --- a/crates/nu-command/src/commands/count.rs +++ b/crates/nu-command/src/commands/count.rs @@ -81,6 +81,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Count {})?) + test_examples(Count {}) } } diff --git a/crates/nu-command/src/commands/cp.rs b/crates/nu-command/src/commands/cp.rs index 591f40ed4b..3eedefc906 100644 --- a/crates/nu-command/src/commands/cp.rs +++ b/crates/nu-command/src/commands/cp.rs @@ -58,6 +58,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Cpy {})?) + test_examples(Cpy {}) } } diff --git a/crates/nu-command/src/commands/date/command.rs b/crates/nu-command/src/commands/date/command.rs index 146ee3ff82..6ebce001c8 100644 --- a/crates/nu-command/src/commands/date/command.rs +++ b/crates/nu-command/src/commands/date/command.rs @@ -35,6 +35,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Command {})?) + test_examples(Command {}) } } diff --git a/crates/nu-command/src/commands/date/format.rs b/crates/nu-command/src/commands/date/format.rs index dfb6efeb35..01893da306 100644 --- a/crates/nu-command/src/commands/date/format.rs +++ b/crates/nu-command/src/commands/date/format.rs @@ -104,6 +104,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Date {})?) + test_examples(Date {}) } } diff --git a/crates/nu-command/src/commands/date/list_timezone.rs b/crates/nu-command/src/commands/date/list_timezone.rs index 9d6595ef88..9c5d47b3ec 100644 --- a/crates/nu-command/src/commands/date/list_timezone.rs +++ b/crates/nu-command/src/commands/date/list_timezone.rs @@ -70,6 +70,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Date {})?) + test_examples(Date {}) } } diff --git a/crates/nu-command/src/commands/date/now.rs b/crates/nu-command/src/commands/date/now.rs index da66b56e1b..386dd964d9 100644 --- a/crates/nu-command/src/commands/date/now.rs +++ b/crates/nu-command/src/commands/date/now.rs @@ -45,6 +45,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Date {})?) + test_examples(Date {}) } } diff --git a/crates/nu-command/src/commands/date/to_table.rs b/crates/nu-command/src/commands/date/to_table.rs index 3a117759e7..656c8133fa 100644 --- a/crates/nu-command/src/commands/date/to_table.rs +++ b/crates/nu-command/src/commands/date/to_table.rs @@ -100,6 +100,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Date {})?) + test_examples(Date {}) } } diff --git a/crates/nu-command/src/commands/date/to_timezone.rs b/crates/nu-command/src/commands/date/to_timezone.rs index 9fb194a882..e0da422c6a 100644 --- a/crates/nu-command/src/commands/date/to_timezone.rs +++ b/crates/nu-command/src/commands/date/to_timezone.rs @@ -105,6 +105,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Date {})?) + test_examples(Date {}) } } diff --git a/crates/nu-command/src/commands/date/utc.rs b/crates/nu-command/src/commands/date/utc.rs index 79d7b94c19..d5f2d81b36 100644 --- a/crates/nu-command/src/commands/date/utc.rs +++ b/crates/nu-command/src/commands/date/utc.rs @@ -50,6 +50,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Date {})?) + test_examples(Date {}) } } diff --git a/crates/nu-command/src/commands/debug.rs b/crates/nu-command/src/commands/debug.rs index ef1ac91f83..085c1b5fd7 100644 --- a/crates/nu-command/src/commands/debug.rs +++ b/crates/nu-command/src/commands/debug.rs @@ -53,6 +53,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Debug {})?) + test_examples(Debug {}) } } diff --git a/crates/nu-command/src/commands/default.rs b/crates/nu-command/src/commands/default.rs index fe275b1e8c..a0f2d77ffb 100644 --- a/crates/nu-command/src/commands/default.rs +++ b/crates/nu-command/src/commands/default.rs @@ -80,6 +80,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Default {})?) + test_examples(Default {}) } } diff --git a/crates/nu-command/src/commands/describe.rs b/crates/nu-command/src/commands/describe.rs index 0ae2eda3d5..64a69dc4c5 100644 --- a/crates/nu-command/src/commands/describe.rs +++ b/crates/nu-command/src/commands/describe.rs @@ -49,6 +49,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Describe {})?) + test_examples(Describe {}) } } diff --git a/crates/nu-command/src/commands/do_.rs b/crates/nu-command/src/commands/do_.rs index c1c08cbfb5..138a275b7a 100644 --- a/crates/nu-command/src/commands/do_.rs +++ b/crates/nu-command/src/commands/do_.rs @@ -113,6 +113,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Do {})?) + test_examples(Do {}) } } diff --git a/crates/nu-command/src/commands/drop.rs b/crates/nu-command/src/commands/drop.rs index 526a16f8e6..684b3e268c 100644 --- a/crates/nu-command/src/commands/drop.rs +++ b/crates/nu-command/src/commands/drop.rs @@ -86,6 +86,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Drop {})?) + test_examples(Drop {}) } } diff --git a/crates/nu-command/src/commands/du.rs b/crates/nu-command/src/commands/du.rs index a6261aa2a0..2907d5a476 100644 --- a/crates/nu-command/src/commands/du.rs +++ b/crates/nu-command/src/commands/du.rs @@ -168,6 +168,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Du {})?) + test_examples(Du {}) } } diff --git a/crates/nu-command/src/commands/each/command.rs b/crates/nu-command/src/commands/each/command.rs index dfb5dbae9f..db1649e0c0 100644 --- a/crates/nu-command/src/commands/each/command.rs +++ b/crates/nu-command/src/commands/each/command.rs @@ -160,6 +160,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Each {})?) + test_examples(Each {}) } } diff --git a/crates/nu-command/src/commands/each/group.rs b/crates/nu-command/src/commands/each/group.rs index b7fbcabd36..bd3d6fadd5 100644 --- a/crates/nu-command/src/commands/each/group.rs +++ b/crates/nu-command/src/commands/each/group.rs @@ -111,6 +111,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(EachGroup {})?) + test_examples(EachGroup {}) } } diff --git a/crates/nu-command/src/commands/each/window.rs b/crates/nu-command/src/commands/each/window.rs index 9343d3e29a..1e8ad90f21 100644 --- a/crates/nu-command/src/commands/each/window.rs +++ b/crates/nu-command/src/commands/each/window.rs @@ -100,6 +100,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(EachWindow {})?) + test_examples(EachWindow {}) } } diff --git a/crates/nu-command/src/commands/echo.rs b/crates/nu-command/src/commands/echo.rs index 3db5c7a79a..822964755a 100644 --- a/crates/nu-command/src/commands/echo.rs +++ b/crates/nu-command/src/commands/echo.rs @@ -200,6 +200,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Echo {})?) + test_examples(Echo {}) } } diff --git a/crates/nu-command/src/commands/enter.rs b/crates/nu-command/src/commands/enter.rs index 9baf77a72c..76308b3610 100644 --- a/crates/nu-command/src/commands/enter.rs +++ b/crates/nu-command/src/commands/enter.rs @@ -189,6 +189,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Enter {})?) + test_examples(Enter {}) } } diff --git a/crates/nu-command/src/commands/every.rs b/crates/nu-command/src/commands/every.rs index e06bd411f3..d5a716ba88 100644 --- a/crates/nu-command/src/commands/every.rs +++ b/crates/nu-command/src/commands/every.rs @@ -93,6 +93,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Every {})?) + test_examples(Every {}) } } diff --git a/crates/nu-command/src/commands/exit.rs b/crates/nu-command/src/commands/exit.rs index 08bb53f884..3bc68398a4 100644 --- a/crates/nu-command/src/commands/exit.rs +++ b/crates/nu-command/src/commands/exit.rs @@ -59,6 +59,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Exit {})?) + test_examples(Exit {}) } } diff --git a/crates/nu-command/src/commands/first.rs b/crates/nu-command/src/commands/first.rs index ae056c0dd6..3ba376c2c3 100644 --- a/crates/nu-command/src/commands/first.rs +++ b/crates/nu-command/src/commands/first.rs @@ -72,6 +72,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(First {})?) + test_examples(First {}) } } diff --git a/crates/nu-command/src/commands/flatten.rs b/crates/nu-command/src/commands/flatten.rs index 301772986b..3cb4bcfc2f 100644 --- a/crates/nu-command/src/commands/flatten.rs +++ b/crates/nu-command/src/commands/flatten.rs @@ -57,9 +57,7 @@ async fn flatten(args: CommandArgs) -> Result { let (Arguments { rest: columns }, input) = args.process().await?; Ok(input - .map(move |item| { - futures::stream::iter(flat_value(&columns, &item, &tag).into_iter().flatten()) - }) + .map(move |item| futures::stream::iter(flat_value(&columns, &item, &tag).into_iter())) .flatten() .to_output_stream()) } @@ -72,7 +70,7 @@ fn flat_value( columns: &[Tagged], item: &Value, name_tag: impl Into, -) -> Result>, ShellError> { +) -> Vec> { let tag = item.tag.clone(); let name_tag = name_tag.into(); @@ -121,7 +119,7 @@ fn flat_value( name_tag.span }; - return Ok(vec![ReturnSuccess::value( + return vec![ReturnSuccess::value( UntaggedValue::Error(ShellError::labeled_error_with_secondary( "can only flatten one inner table at the same time", "tried flattening more than one column with inner tables", @@ -130,7 +128,7 @@ fn flat_value( already_flattened, )) .into_value(name_tag), - )]); + )]; } if !columns.is_empty() { @@ -179,5 +177,5 @@ fn flat_value( } }; - Ok(res.into_iter().map(ReturnSuccess::value).collect()) + res.into_iter().map(ReturnSuccess::value).collect() } diff --git a/crates/nu-command/src/commands/format/command.rs b/crates/nu-command/src/commands/format/command.rs index 3fb1b75bce..241528bfaf 100644 --- a/crates/nu-command/src/commands/format/command.rs +++ b/crates/nu-command/src/commands/format/command.rs @@ -145,6 +145,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Format {})?) + test_examples(Format {}) } } diff --git a/crates/nu-command/src/commands/format/format_filesize.rs b/crates/nu-command/src/commands/format/format_filesize.rs index e87a0d90fc..5916b96082 100644 --- a/crates/nu-command/src/commands/format/format_filesize.rs +++ b/crates/nu-command/src/commands/format/format_filesize.rs @@ -121,6 +121,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(FileSize {})?) + test_examples(FileSize {}) } } diff --git a/crates/nu-command/src/commands/from.rs b/crates/nu-command/src/commands/from.rs index 7a5b468c17..0dcec25172 100644 --- a/crates/nu-command/src/commands/from.rs +++ b/crates/nu-command/src/commands/from.rs @@ -35,6 +35,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(From {})?) + test_examples(From {}) } } diff --git a/crates/nu-command/src/commands/from_csv.rs b/crates/nu-command/src/commands/from_csv.rs index 8c16bf8e0c..576bb2d97a 100644 --- a/crates/nu-command/src/commands/from_csv.rs +++ b/crates/nu-command/src/commands/from_csv.rs @@ -107,6 +107,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(FromCSV {})?) + test_examples(FromCSV {}) } } diff --git a/crates/nu-command/src/commands/from_eml.rs b/crates/nu-command/src/commands/from_eml.rs index a818b2448d..d1026de672 100644 --- a/crates/nu-command/src/commands/from_eml.rs +++ b/crates/nu-command/src/commands/from_eml.rs @@ -128,6 +128,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(FromEML {})?) + test_examples(FromEML {}) } } diff --git a/crates/nu-command/src/commands/from_ics.rs b/crates/nu-command/src/commands/from_ics.rs index 6ba93ea692..61e0ce2b8a 100644 --- a/crates/nu-command/src/commands/from_ics.rs +++ b/crates/nu-command/src/commands/from_ics.rs @@ -247,6 +247,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(FromIcs {})?) + test_examples(FromIcs {}) } } diff --git a/crates/nu-command/src/commands/from_ini.rs b/crates/nu-command/src/commands/from_ini.rs index 8b1ad288d0..4ddc8e7684 100644 --- a/crates/nu-command/src/commands/from_ini.rs +++ b/crates/nu-command/src/commands/from_ini.rs @@ -93,6 +93,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(FromINI {})?) + test_examples(FromINI {}) } } diff --git a/crates/nu-command/src/commands/from_json.rs b/crates/nu-command/src/commands/from_json.rs index 752df27786..f43ce18162 100644 --- a/crates/nu-command/src/commands/from_json.rs +++ b/crates/nu-command/src/commands/from_json.rs @@ -142,6 +142,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(FromJSON {})?) + test_examples(FromJSON {}) } } diff --git a/crates/nu-command/src/commands/from_ods.rs b/crates/nu-command/src/commands/from_ods.rs index 678ae52302..e933d7af97 100644 --- a/crates/nu-command/src/commands/from_ods.rs +++ b/crates/nu-command/src/commands/from_ods.rs @@ -100,6 +100,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(FromODS {})?) + test_examples(FromODS {}) } } diff --git a/crates/nu-command/src/commands/from_ssv.rs b/crates/nu-command/src/commands/from_ssv.rs index 5bbaaac71b..8fca94fdba 100644 --- a/crates/nu-command/src/commands/from_ssv.rs +++ b/crates/nu-command/src/commands/from_ssv.rs @@ -227,7 +227,7 @@ fn from_ssv_string_to_value( aligned_columns: bool, split_at: usize, tag: impl Into, -) -> Option { +) -> Value { let tag = tag.into(); let rows = string_to_table(s, headerless, aligned_columns, split_at) .iter() @@ -244,7 +244,7 @@ fn from_ssv_string_to_value( }) .collect(); - Some(UntaggedValue::Table(rows).into_value(&tag)) + UntaggedValue::Table(rows).into_value(&tag) } async fn from_ssv(args: CommandArgs) -> Result { @@ -271,23 +271,13 @@ async fn from_ssv(args: CommandArgs) -> Result { split_at, name.clone(), ) { - Some(x) => match x { - Value { - value: UntaggedValue::Table(list), - .. - } => futures::stream::iter(list.into_iter().map(ReturnSuccess::value)) - .to_output_stream(), - x => OutputStream::one(ReturnSuccess::value(x)), - }, - None => { - return Err(ShellError::labeled_error_with_secondary( - "Could not parse as SSV", - "input cannot be parsed ssv", - &name, - "value originates from here", - &concat_string.tag, - )); + Value { + value: UntaggedValue::Table(list), + .. + } => { + futures::stream::iter(list.into_iter().map(ReturnSuccess::value)).to_output_stream() } + x => OutputStream::one(ReturnSuccess::value(x)), }, ) } @@ -502,6 +492,6 @@ mod tests { use super::FromSSV; use crate::examples::test as test_examples; - Ok(test_examples(FromSSV {})?) + test_examples(FromSSV {}) } } diff --git a/crates/nu-command/src/commands/from_toml.rs b/crates/nu-command/src/commands/from_toml.rs index f1ad40517b..15b8061bef 100644 --- a/crates/nu-command/src/commands/from_toml.rs +++ b/crates/nu-command/src/commands/from_toml.rs @@ -99,6 +99,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(FromTOML {})?) + test_examples(FromTOML {}) } } diff --git a/crates/nu-command/src/commands/from_tsv.rs b/crates/nu-command/src/commands/from_tsv.rs index 3af3c4de5f..4d11c0d2f9 100644 --- a/crates/nu-command/src/commands/from_tsv.rs +++ b/crates/nu-command/src/commands/from_tsv.rs @@ -50,6 +50,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(FromTSV {})?) + test_examples(FromTSV {}) } } diff --git a/crates/nu-command/src/commands/from_url.rs b/crates/nu-command/src/commands/from_url.rs index 4d93884ded..2275b55171 100644 --- a/crates/nu-command/src/commands/from_url.rs +++ b/crates/nu-command/src/commands/from_url.rs @@ -62,6 +62,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(FromURL {})?) + test_examples(FromURL {}) } } diff --git a/crates/nu-command/src/commands/from_vcf.rs b/crates/nu-command/src/commands/from_vcf.rs index 06f20d11c3..7020bc5c22 100644 --- a/crates/nu-command/src/commands/from_vcf.rs +++ b/crates/nu-command/src/commands/from_vcf.rs @@ -102,6 +102,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(FromVcf {})?) + test_examples(FromVcf {}) } } diff --git a/crates/nu-command/src/commands/from_xlsx.rs b/crates/nu-command/src/commands/from_xlsx.rs index 9a8766940b..16adf79db2 100644 --- a/crates/nu-command/src/commands/from_xlsx.rs +++ b/crates/nu-command/src/commands/from_xlsx.rs @@ -100,6 +100,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(FromXLSX {})?) + test_examples(FromXLSX {}) } } diff --git a/crates/nu-command/src/commands/from_xml.rs b/crates/nu-command/src/commands/from_xml.rs index e458df84c8..c8ddeb2637 100644 --- a/crates/nu-command/src/commands/from_xml.rs +++ b/crates/nu-command/src/commands/from_xml.rs @@ -301,6 +301,6 @@ mod tests { use super::FromXML; use crate::examples::test as test_examples; - Ok(test_examples(FromXML {})?) + test_examples(FromXML {}) } } diff --git a/crates/nu-command/src/commands/from_yaml.rs b/crates/nu-command/src/commands/from_yaml.rs index 90df48b180..d631c8eca0 100644 --- a/crates/nu-command/src/commands/from_yaml.rs +++ b/crates/nu-command/src/commands/from_yaml.rs @@ -130,7 +130,7 @@ pub fn from_yaml_string_to_value(s: String, tag: impl Into) -> Result Result { @@ -169,7 +169,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(FromYAML {})?) + test_examples(FromYAML {}) } #[test] diff --git a/crates/nu-command/src/commands/group_by_date.rs b/crates/nu-command/src/commands/group_by_date.rs index c09d7ce423..5bc354ae14 100644 --- a/crates/nu-command/src/commands/group_by_date.rs +++ b/crates/nu-command/src/commands/group_by_date.rs @@ -139,6 +139,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(GroupByDate {})?) + test_examples(GroupByDate {}) } } diff --git a/crates/nu-command/src/commands/hash_/command.rs b/crates/nu-command/src/commands/hash_/command.rs index 05bf8b6818..d19f5d7f4a 100644 --- a/crates/nu-command/src/commands/hash_/command.rs +++ b/crates/nu-command/src/commands/hash_/command.rs @@ -38,6 +38,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Command {})?) + test_examples(Command {}) } } diff --git a/crates/nu-command/src/commands/headers.rs b/crates/nu-command/src/commands/headers.rs index 95ce2dac1c..12b4697592 100644 --- a/crates/nu-command/src/commands/headers.rs +++ b/crates/nu-command/src/commands/headers.rs @@ -114,6 +114,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Headers {})?) + test_examples(Headers {}) } } diff --git a/crates/nu-command/src/commands/help.rs b/crates/nu-command/src/commands/help.rs index 7cf1e18176..053fc74b89 100644 --- a/crates/nu-command/src/commands/help.rs +++ b/crates/nu-command/src/commands/help.rs @@ -217,6 +217,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Help {})?) + test_examples(Help {}) } } diff --git a/crates/nu-command/src/commands/histogram.rs b/crates/nu-command/src/commands/histogram.rs index fa92a1ec36..059fc26664 100644 --- a/crates/nu-command/src/commands/histogram.rs +++ b/crates/nu-command/src/commands/histogram.rs @@ -225,6 +225,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Histogram {})?) + test_examples(Histogram {}) } } diff --git a/crates/nu-command/src/commands/history.rs b/crates/nu-command/src/commands/history.rs index 27d7cf1022..29bb1bb772 100644 --- a/crates/nu-command/src/commands/history.rs +++ b/crates/nu-command/src/commands/history.rs @@ -77,6 +77,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(History {})?) + test_examples(History {}) } } diff --git a/crates/nu-command/src/commands/if_.rs b/crates/nu-command/src/commands/if_.rs index cd5b1fff4b..13e97f0a14 100644 --- a/crates/nu-command/src/commands/if_.rs +++ b/crates/nu-command/src/commands/if_.rs @@ -137,6 +137,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(If {})?) + test_examples(If {}) } } diff --git a/crates/nu-command/src/commands/into_int.rs b/crates/nu-command/src/commands/into_int.rs index 2902ef61a3..73e0a8784e 100644 --- a/crates/nu-command/src/commands/into_int.rs +++ b/crates/nu-command/src/commands/into_int.rs @@ -83,6 +83,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(IntoInt {})?) + test_examples(IntoInt {}) } } diff --git a/crates/nu-command/src/commands/keep/command.rs b/crates/nu-command/src/commands/keep/command.rs index 05787bcf01..84d561cf86 100644 --- a/crates/nu-command/src/commands/keep/command.rs +++ b/crates/nu-command/src/commands/keep/command.rs @@ -74,6 +74,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Command {})?) + test_examples(Command {}) } } diff --git a/crates/nu-command/src/commands/keep/until.rs b/crates/nu-command/src/commands/keep/until.rs index e7d09b24ff..ffe2987620 100644 --- a/crates/nu-command/src/commands/keep/until.rs +++ b/crates/nu-command/src/commands/keep/until.rs @@ -109,6 +109,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/keep/while_.rs b/crates/nu-command/src/commands/keep/while_.rs index d1cb42b409..95f848342d 100644 --- a/crates/nu-command/src/commands/keep/while_.rs +++ b/crates/nu-command/src/commands/keep/while_.rs @@ -108,6 +108,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/kill.rs b/crates/nu-command/src/commands/kill.rs index fff2daf7bf..8ba68c6dc0 100644 --- a/crates/nu-command/src/commands/kill.rs +++ b/crates/nu-command/src/commands/kill.rs @@ -120,6 +120,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Kill {})?) + test_examples(Kill {}) } } diff --git a/crates/nu-command/src/commands/last.rs b/crates/nu-command/src/commands/last.rs index 5431020bac..da90055780 100644 --- a/crates/nu-command/src/commands/last.rs +++ b/crates/nu-command/src/commands/last.rs @@ -83,6 +83,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Last {})?) + test_examples(Last {}) } } diff --git a/crates/nu-command/src/commands/lines.rs b/crates/nu-command/src/commands/lines.rs index 942c00c573..9d9d67f0a6 100644 --- a/crates/nu-command/src/commands/lines.rs +++ b/crates/nu-command/src/commands/lines.rs @@ -124,6 +124,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Lines {})?) + test_examples(Lines {}) } } diff --git a/crates/nu-command/src/commands/ls.rs b/crates/nu-command/src/commands/ls.rs index 94dc5d2b99..7e646c7675 100644 --- a/crates/nu-command/src/commands/ls.rs +++ b/crates/nu-command/src/commands/ls.rs @@ -78,6 +78,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Ls {})?) + test_examples(Ls {}) } } diff --git a/crates/nu-command/src/commands/math/abs.rs b/crates/nu-command/src/commands/math/abs.rs index 44dada2bf7..00a9e1724f 100644 --- a/crates/nu-command/src/commands/math/abs.rs +++ b/crates/nu-command/src/commands/math/abs.rs @@ -64,6 +64,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/math/avg.rs b/crates/nu-command/src/commands/math/avg.rs index 8b39414a04..1408e3549e 100644 --- a/crates/nu-command/src/commands/math/avg.rs +++ b/crates/nu-command/src/commands/math/avg.rs @@ -187,6 +187,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/math/ceil.rs b/crates/nu-command/src/commands/math/ceil.rs index 2adfc07241..cc66bdc855 100644 --- a/crates/nu-command/src/commands/math/ceil.rs +++ b/crates/nu-command/src/commands/math/ceil.rs @@ -81,6 +81,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/math/command.rs b/crates/nu-command/src/commands/math/command.rs index 1330bd5438..843a1b4655 100644 --- a/crates/nu-command/src/commands/math/command.rs +++ b/crates/nu-command/src/commands/math/command.rs @@ -41,7 +41,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Command {})?) + test_examples(Command {}) } #[test] diff --git a/crates/nu-command/src/commands/math/eval.rs b/crates/nu-command/src/commands/math/eval.rs index 33aef8428f..32bc9f9166 100644 --- a/crates/nu-command/src/commands/math/eval.rs +++ b/crates/nu-command/src/commands/math/eval.rs @@ -113,6 +113,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/math/floor.rs b/crates/nu-command/src/commands/math/floor.rs index 787206b64d..50776b1f26 100644 --- a/crates/nu-command/src/commands/math/floor.rs +++ b/crates/nu-command/src/commands/math/floor.rs @@ -81,6 +81,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/math/max.rs b/crates/nu-command/src/commands/math/max.rs index 62407f2ce8..8e8e0222a7 100644 --- a/crates/nu-command/src/commands/math/max.rs +++ b/crates/nu-command/src/commands/math/max.rs @@ -60,6 +60,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/math/median.rs b/crates/nu-command/src/commands/math/median.rs index 0e6ff5c448..d73e564ddf 100644 --- a/crates/nu-command/src/commands/math/median.rs +++ b/crates/nu-command/src/commands/math/median.rs @@ -189,6 +189,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/math/min.rs b/crates/nu-command/src/commands/math/min.rs index 03b55d27ee..1578a89975 100644 --- a/crates/nu-command/src/commands/math/min.rs +++ b/crates/nu-command/src/commands/math/min.rs @@ -60,6 +60,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/math/mode.rs b/crates/nu-command/src/commands/math/mode.rs index d79a8610c1..3c87af3c67 100644 --- a/crates/nu-command/src/commands/math/mode.rs +++ b/crates/nu-command/src/commands/math/mode.rs @@ -85,6 +85,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/math/product.rs b/crates/nu-command/src/commands/math/product.rs index 906dc0d151..0216fff1f8 100644 --- a/crates/nu-command/src/commands/math/product.rs +++ b/crates/nu-command/src/commands/math/product.rs @@ -111,6 +111,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/math/round.rs b/crates/nu-command/src/commands/math/round.rs index fafe4d4b4a..33000fcbe8 100644 --- a/crates/nu-command/src/commands/math/round.rs +++ b/crates/nu-command/src/commands/math/round.rs @@ -99,6 +99,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/math/stddev.rs b/crates/nu-command/src/commands/math/stddev.rs index c6f4e40afa..0766de9d2c 100644 --- a/crates/nu-command/src/commands/math/stddev.rs +++ b/crates/nu-command/src/commands/math/stddev.rs @@ -144,6 +144,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/math/sum.rs b/crates/nu-command/src/commands/math/sum.rs index bfd309d20e..08105340bd 100644 --- a/crates/nu-command/src/commands/math/sum.rs +++ b/crates/nu-command/src/commands/math/sum.rs @@ -125,6 +125,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/math/variance.rs b/crates/nu-command/src/commands/math/variance.rs index a6b6a81f91..4ab6af858a 100644 --- a/crates/nu-command/src/commands/math/variance.rs +++ b/crates/nu-command/src/commands/math/variance.rs @@ -243,6 +243,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/merge.rs b/crates/nu-command/src/commands/merge.rs index be3914e99f..9122a1202b 100644 --- a/crates/nu-command/src/commands/merge.rs +++ b/crates/nu-command/src/commands/merge.rs @@ -103,6 +103,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Merge {})?) + test_examples(Merge {}) } } diff --git a/crates/nu-command/src/commands/mkdir.rs b/crates/nu-command/src/commands/mkdir.rs index 4850bdba9a..8b420eb962 100644 --- a/crates/nu-command/src/commands/mkdir.rs +++ b/crates/nu-command/src/commands/mkdir.rs @@ -53,6 +53,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Mkdir {})?) + test_examples(Mkdir {}) } } diff --git a/crates/nu-command/src/commands/move_/mv.rs b/crates/nu-command/src/commands/move_/mv.rs index 0d38e3d3d4..2f480021aa 100644 --- a/crates/nu-command/src/commands/move_/mv.rs +++ b/crates/nu-command/src/commands/move_/mv.rs @@ -71,6 +71,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Mv {})?) + test_examples(Mv {}) } } diff --git a/crates/nu-command/src/commands/next.rs b/crates/nu-command/src/commands/next.rs index 5c451c4445..0914dbd6a3 100644 --- a/crates/nu-command/src/commands/next.rs +++ b/crates/nu-command/src/commands/next.rs @@ -20,12 +20,12 @@ impl WholeStreamCommand for Next { } async fn run(&self, args: CommandArgs) -> Result { - next(args) + Ok(next(args)) } } -fn next(_args: CommandArgs) -> Result { - Ok(vec![Ok(ReturnSuccess::Action(CommandAction::NextShell))].into()) +fn next(_args: CommandArgs) -> OutputStream { + vec![Ok(ReturnSuccess::Action(CommandAction::NextShell))].into() } #[cfg(test)] @@ -37,6 +37,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Next {})?) + test_examples(Next {}) } } diff --git a/crates/nu-command/src/commands/nth.rs b/crates/nu-command/src/commands/nth.rs index be88a7ce7d..528cb144c8 100644 --- a/crates/nu-command/src/commands/nth.rs +++ b/crates/nu-command/src/commands/nth.rs @@ -96,6 +96,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Nth {})?) + test_examples(Nth {}) } } diff --git a/crates/nu-command/src/commands/nu/plugin.rs b/crates/nu-command/src/commands/nu/plugin.rs index 7da2478e2d..3fb76d8ab5 100644 --- a/crates/nu-command/src/commands/nu/plugin.rs +++ b/crates/nu-command/src/commands/nu/plugin.rs @@ -115,6 +115,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/open.rs b/crates/nu-command/src/commands/open.rs index 4dc414d6d0..1ceaa434f0 100644 --- a/crates/nu-command/src/commands/open.rs +++ b/crates/nu-command/src/commands/open.rs @@ -8,7 +8,7 @@ use nu_engine::WholeStreamCommand; use nu_errors::ShellError; use nu_protocol::{CommandAction, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value}; use nu_source::{AnchorLocation, Span, Tagged}; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; pub struct Open; @@ -180,13 +180,13 @@ async fn open(args: CommandArgs) -> Result { // Note that we do not output a Stream in "fetch" since it is only used by "enter" command // Which we expect to use a concrete Value a not a Stream pub async fn fetch( - cwd: &PathBuf, - location: &PathBuf, + cwd: &Path, + location: &Path, span: Span, encoding_choice: Option>, ) -> Result<(Option, Value), ShellError> { // TODO: I don't understand the point of this? Maybe for better error reporting - let mut cwd = cwd.clone(); + let mut cwd = PathBuf::from(cwd); cwd.push(location); let nice_location = dunce::canonicalize(&cwd).map_err(|e| match e.kind() { std::io::ErrorKind::NotFound => ShellError::labeled_error( @@ -254,6 +254,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Open {})?) + test_examples(Open {}) } } diff --git a/crates/nu-command/src/commands/parse/command.rs b/crates/nu-command/src/commands/parse/command.rs index dae4c3caaf..a5e95f9177 100644 --- a/crates/nu-command/src/commands/parse/command.rs +++ b/crates/nu-command/src/commands/parse/command.rs @@ -175,6 +175,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Command {})?) + test_examples(Command {}) } } diff --git a/crates/nu-command/src/commands/path/basename.rs b/crates/nu-command/src/commands/path/basename.rs index b8e7aa8ddf..3d72180e07 100644 --- a/crates/nu-command/src/commands/path/basename.rs +++ b/crates/nu-command/src/commands/path/basename.rs @@ -104,6 +104,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(PathBasename {})?) + test_examples(PathBasename {}) } } diff --git a/crates/nu-command/src/commands/path/command.rs b/crates/nu-command/src/commands/path/command.rs index f12fca07a6..539793f4c6 100644 --- a/crates/nu-command/src/commands/path/command.rs +++ b/crates/nu-command/src/commands/path/command.rs @@ -35,6 +35,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Path {})?) + test_examples(Path {}) } } diff --git a/crates/nu-command/src/commands/path/dirname.rs b/crates/nu-command/src/commands/path/dirname.rs index 9c1d7d4272..a1be395388 100644 --- a/crates/nu-command/src/commands/path/dirname.rs +++ b/crates/nu-command/src/commands/path/dirname.rs @@ -150,6 +150,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(PathDirname {})?) + test_examples(PathDirname {}) } } diff --git a/crates/nu-command/src/commands/path/exists.rs b/crates/nu-command/src/commands/path/exists.rs index 2eac3df003..9539014a87 100644 --- a/crates/nu-command/src/commands/path/exists.rs +++ b/crates/nu-command/src/commands/path/exists.rs @@ -72,6 +72,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(PathExists {})?) + test_examples(PathExists {}) } } diff --git a/crates/nu-command/src/commands/path/expand.rs b/crates/nu-command/src/commands/path/expand.rs index 849d1ed262..8ebac32707 100644 --- a/crates/nu-command/src/commands/path/expand.rs +++ b/crates/nu-command/src/commands/path/expand.rs @@ -77,6 +77,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(PathExpand {})?) + test_examples(PathExpand {}) } } diff --git a/crates/nu-command/src/commands/path/extension.rs b/crates/nu-command/src/commands/path/extension.rs index 490bec6662..380f84e59d 100644 --- a/crates/nu-command/src/commands/path/extension.rs +++ b/crates/nu-command/src/commands/path/extension.rs @@ -93,6 +93,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(PathExtension {})?) + test_examples(PathExtension {}) } } diff --git a/crates/nu-command/src/commands/path/filestem.rs b/crates/nu-command/src/commands/path/filestem.rs index 6e70375d0a..e31fa63f38 100644 --- a/crates/nu-command/src/commands/path/filestem.rs +++ b/crates/nu-command/src/commands/path/filestem.rs @@ -167,6 +167,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(PathFilestem {})?) + test_examples(PathFilestem {}) } } diff --git a/crates/nu-command/src/commands/path/type.rs b/crates/nu-command/src/commands/path/type.rs index bbb74b51a4..65debdfc7a 100644 --- a/crates/nu-command/src/commands/path/type.rs +++ b/crates/nu-command/src/commands/path/type.rs @@ -67,6 +67,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(PathType {})?) + test_examples(PathType {}) } } diff --git a/crates/nu-command/src/commands/pivot.rs b/crates/nu-command/src/commands/pivot.rs index 76473fecef..dd282219a7 100644 --- a/crates/nu-command/src/commands/pivot.rs +++ b/crates/nu-command/src/commands/pivot.rs @@ -153,6 +153,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Pivot {})?) + test_examples(Pivot {}) } } diff --git a/crates/nu-command/src/commands/prepend.rs b/crates/nu-command/src/commands/prepend.rs index 47b09466f5..7a6c476546 100644 --- a/crates/nu-command/src/commands/prepend.rs +++ b/crates/nu-command/src/commands/prepend.rs @@ -63,6 +63,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Prepend {})?) + test_examples(Prepend {}) } } diff --git a/crates/nu-command/src/commands/prev.rs b/crates/nu-command/src/commands/prev.rs index 8e8201bccc..eababdfb63 100644 --- a/crates/nu-command/src/commands/prev.rs +++ b/crates/nu-command/src/commands/prev.rs @@ -21,12 +21,12 @@ impl WholeStreamCommand for Previous { } async fn run(&self, args: CommandArgs) -> Result { - previous(args) + Ok(previous(args)) } } -fn previous(_args: CommandArgs) -> Result { - Ok(vec![Ok(ReturnSuccess::Action(CommandAction::PreviousShell))].into()) +fn previous(_args: CommandArgs) -> OutputStream { + vec![Ok(ReturnSuccess::Action(CommandAction::PreviousShell))].into() } #[cfg(test)] @@ -38,6 +38,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Previous {})?) + test_examples(Previous {}) } } diff --git a/crates/nu-command/src/commands/pwd.rs b/crates/nu-command/src/commands/pwd.rs index da3fa4c002..f28c1c8ba4 100644 --- a/crates/nu-command/src/commands/pwd.rs +++ b/crates/nu-command/src/commands/pwd.rs @@ -48,6 +48,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Pwd {})?) + test_examples(Pwd {}) } } diff --git a/crates/nu-command/src/commands/random/bool.rs b/crates/nu-command/src/commands/random/bool.rs index ab6fe7f1c5..9f0fe83237 100644 --- a/crates/nu-command/src/commands/random/bool.rs +++ b/crates/nu-command/src/commands/random/bool.rs @@ -86,6 +86,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/random/chars.rs b/crates/nu-command/src/commands/random/chars.rs index 65885e3763..e2e73c3602 100644 --- a/crates/nu-command/src/commands/random/chars.rs +++ b/crates/nu-command/src/commands/random/chars.rs @@ -77,6 +77,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/random/decimal.rs b/crates/nu-command/src/commands/random/decimal.rs index 65cee4b0a1..e3a17c1271 100644 --- a/crates/nu-command/src/commands/random/decimal.rs +++ b/crates/nu-command/src/commands/random/decimal.rs @@ -99,6 +99,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/random/dice.rs b/crates/nu-command/src/commands/random/dice.rs index 1bc56f8e16..868086147a 100644 --- a/crates/nu-command/src/commands/random/dice.rs +++ b/crates/nu-command/src/commands/random/dice.rs @@ -92,6 +92,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/random/integer.rs b/crates/nu-command/src/commands/random/integer.rs index 80ffb4d89d..4aa8187152 100644 --- a/crates/nu-command/src/commands/random/integer.rs +++ b/crates/nu-command/src/commands/random/integer.rs @@ -101,6 +101,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/random/uuid.rs b/crates/nu-command/src/commands/random/uuid.rs index 0bd060935f..9eca754316 100644 --- a/crates/nu-command/src/commands/random/uuid.rs +++ b/crates/nu-command/src/commands/random/uuid.rs @@ -48,6 +48,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/range.rs b/crates/nu-command/src/commands/range.rs index 3f60ada122..a556fd133f 100644 --- a/crates/nu-command/src/commands/range.rs +++ b/crates/nu-command/src/commands/range.rs @@ -72,6 +72,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Range {})?) + test_examples(Range {}) } } diff --git a/crates/nu-command/src/commands/reduce.rs b/crates/nu-command/src/commands/reduce.rs index 2519355762..ebb3c215be 100644 --- a/crates/nu-command/src/commands/reduce.rs +++ b/crates/nu-command/src/commands/reduce.rs @@ -195,6 +195,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Reduce {})?) + test_examples(Reduce {}) } } diff --git a/crates/nu-command/src/commands/reject.rs b/crates/nu-command/src/commands/reject.rs index b58c22f2aa..4bd259f19d 100644 --- a/crates/nu-command/src/commands/reject.rs +++ b/crates/nu-command/src/commands/reject.rs @@ -66,6 +66,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Reject {})?) + test_examples(Reject {}) } } diff --git a/crates/nu-command/src/commands/rename.rs b/crates/nu-command/src/commands/rename.rs index 95d83c2bc3..82254a0532 100644 --- a/crates/nu-command/src/commands/rename.rs +++ b/crates/nu-command/src/commands/rename.rs @@ -115,6 +115,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Rename {})?) + test_examples(Rename {}) } } diff --git a/crates/nu-command/src/commands/reverse.rs b/crates/nu-command/src/commands/reverse.rs index 8061af7665..1ac3659327 100644 --- a/crates/nu-command/src/commands/reverse.rs +++ b/crates/nu-command/src/commands/reverse.rs @@ -55,6 +55,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Reverse {})?) + test_examples(Reverse {}) } } diff --git a/crates/nu-command/src/commands/rm.rs b/crates/nu-command/src/commands/rm.rs index 77bef9fe55..aa08b0991a 100644 --- a/crates/nu-command/src/commands/rm.rs +++ b/crates/nu-command/src/commands/rm.rs @@ -88,6 +88,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Remove {})?) + test_examples(Remove {}) } } diff --git a/crates/nu-command/src/commands/save.rs b/crates/nu-command/src/commands/save.rs index 0233b6f200..b2d17effec 100644 --- a/crates/nu-command/src/commands/save.rs +++ b/crates/nu-command/src/commands/save.rs @@ -187,11 +187,9 @@ async fn save(raw_args: CommandArgs) -> Result { if !input.is_empty() { let anchor = input[0].tag.anchor(); - if let Some(path) = anchor { - if let AnchorLocation::File(file) = path { - should_return_file_path_error = false; - full_path.push(Path::new(&file)); - } + if let Some(AnchorLocation::File(file)) = anchor { + should_return_file_path_error = false; + full_path.push(Path::new(&file)); } } @@ -282,6 +280,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Save {})?) + test_examples(Save {}) } } diff --git a/crates/nu-command/src/commands/seq.rs b/crates/nu-command/src/commands/seq.rs index 5f65fa08e3..f7cd72f03c 100644 --- a/crates/nu-command/src/commands/seq.rs +++ b/crates/nu-command/src/commands/seq.rs @@ -170,7 +170,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Seq {})?) + test_examples(Seq {}) } } @@ -259,7 +259,7 @@ pub fn run_seq( Some(term) => escape_sequences(&term[..]), None => separator.clone(), }; - print_seq( + Ok(print_seq( first, step, last, @@ -268,7 +268,7 @@ pub fn run_seq( terminator, widths, padding, - ) + )) } fn done_printing(next: f64, step: f64, last: f64) -> bool { @@ -289,7 +289,7 @@ fn print_seq( terminator: String, pad: bool, padding: usize, -) -> Result { +) -> OutputStream { let mut i = 0isize; let mut value = first + i as f64 * step; let mut ret_str = "".to_owned(); @@ -318,5 +318,5 @@ fn print_seq( .lines() .map(|v| v.to_str_value_create_tag()) .collect(); - Ok(futures::stream::iter(rows.into_iter().map(ReturnSuccess::value)).to_output_stream()) + futures::stream::iter(rows.into_iter().map(ReturnSuccess::value)).to_output_stream() } diff --git a/crates/nu-command/src/commands/seq_dates.rs b/crates/nu-command/src/commands/seq_dates.rs index 9297d22e5a..c8e514202f 100644 --- a/crates/nu-command/src/commands/seq_dates.rs +++ b/crates/nu-command/src/commands/seq_dates.rs @@ -366,6 +366,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SeqDates {})?) + test_examples(SeqDates {}) } } diff --git a/crates/nu-command/src/commands/shells.rs b/crates/nu-command/src/commands/shells.rs index 00b7988d8f..23c90f8324 100644 --- a/crates/nu-command/src/commands/shells.rs +++ b/crates/nu-command/src/commands/shells.rs @@ -21,11 +21,11 @@ impl WholeStreamCommand for Shells { } async fn run(&self, args: CommandArgs) -> Result { - shells(args) + Ok(shells(args)) } } -fn shells(args: CommandArgs) -> Result { +fn shells(args: CommandArgs) -> OutputStream { let mut shells_out = VecDeque::new(); let tag = args.call_info.name_tag; @@ -43,7 +43,7 @@ fn shells(args: CommandArgs) -> Result { shells_out.push_back(dict.into_value()); } - Ok(shells_out.into()) + shells_out.into() } #[cfg(test)] @@ -55,6 +55,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Shells {})?) + test_examples(Shells {}) } } diff --git a/crates/nu-command/src/commands/shuffle.rs b/crates/nu-command/src/commands/shuffle.rs index f47d41150a..629cdc69ea 100644 --- a/crates/nu-command/src/commands/shuffle.rs +++ b/crates/nu-command/src/commands/shuffle.rs @@ -41,6 +41,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Shuffle {})?) + test_examples(Shuffle {}) } } diff --git a/crates/nu-command/src/commands/size.rs b/crates/nu-command/src/commands/size.rs index 897cf0d691..ed4114e1d5 100644 --- a/crates/nu-command/src/commands/size.rs +++ b/crates/nu-command/src/commands/size.rs @@ -24,7 +24,7 @@ impl WholeStreamCommand for Size { } async fn run(&self, args: CommandArgs) -> Result { - size(args) + Ok(size(args)) } fn examples(&self) -> Vec { @@ -55,12 +55,12 @@ impl WholeStreamCommand for Size { } } -fn size(args: CommandArgs) -> Result { +fn size(args: CommandArgs) -> OutputStream { let input = args.input; let tag = args.call_info.name_tag; let name_span = tag.span; - Ok(input + input .map(move |v| { if let Ok(s) = v.as_string() { ReturnSuccess::value(count(&s, &v.tag)) @@ -74,7 +74,7 @@ fn size(args: CommandArgs) -> Result { )) } }) - .to_output_stream()) + .to_output_stream() } fn count(contents: &str, tag: impl Into) -> Value { @@ -122,6 +122,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Size {})?) + test_examples(Size {}) } } diff --git a/crates/nu-command/src/commands/skip/command.rs b/crates/nu-command/src/commands/skip/command.rs index e057aa4485..456425cc1e 100644 --- a/crates/nu-command/src/commands/skip/command.rs +++ b/crates/nu-command/src/commands/skip/command.rs @@ -61,6 +61,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Command {})?) + test_examples(Command {}) } } diff --git a/crates/nu-command/src/commands/skip/until.rs b/crates/nu-command/src/commands/skip/until.rs index 97c2f923d9..22cc52a7c3 100644 --- a/crates/nu-command/src/commands/skip/until.rs +++ b/crates/nu-command/src/commands/skip/until.rs @@ -108,6 +108,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/skip/while_.rs b/crates/nu-command/src/commands/skip/while_.rs index 2ee782377c..7cdd1320df 100644 --- a/crates/nu-command/src/commands/skip/while_.rs +++ b/crates/nu-command/src/commands/skip/while_.rs @@ -109,6 +109,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/sleep.rs b/crates/nu-command/src/commands/sleep.rs index 546f03fc44..df26003983 100644 --- a/crates/nu-command/src/commands/sleep.rs +++ b/crates/nu-command/src/commands/sleep.rs @@ -187,6 +187,6 @@ mod tests { assert!(elapsed >= std::time::Duration::from_secs(1)); assert!(elapsed < std::time::Duration::from_secs(2)); - Ok(results?) + results } } diff --git a/crates/nu-command/src/commands/sort_by.rs b/crates/nu-command/src/commands/sort_by.rs index 5f857bb64f..850958ca4f 100644 --- a/crates/nu-command/src/commands/sort_by.rs +++ b/crates/nu-command/src/commands/sort_by.rs @@ -234,6 +234,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SortBy {})?) + test_examples(SortBy {}) } } diff --git a/crates/nu-command/src/commands/split/chars.rs b/crates/nu-command/src/commands/split/chars.rs index 268b9776f8..604fce9b85 100644 --- a/crates/nu-command/src/commands/split/chars.rs +++ b/crates/nu-command/src/commands/split/chars.rs @@ -73,6 +73,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/split/column.rs b/crates/nu-command/src/commands/split/column.rs index 4d98c9906d..29d343672a 100644 --- a/crates/nu-command/src/commands/split/column.rs +++ b/crates/nu-command/src/commands/split/column.rs @@ -115,6 +115,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/split/command.rs b/crates/nu-command/src/commands/split/command.rs index c3befbe8ba..270d9b197e 100644 --- a/crates/nu-command/src/commands/split/command.rs +++ b/crates/nu-command/src/commands/split/command.rs @@ -36,6 +36,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Command {})?) + test_examples(Command {}) } } diff --git a/crates/nu-command/src/commands/split/row.rs b/crates/nu-command/src/commands/split/row.rs index 4981fa5bc5..24ca3d488b 100644 --- a/crates/nu-command/src/commands/split/row.rs +++ b/crates/nu-command/src/commands/split/row.rs @@ -84,6 +84,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/split_by.rs b/crates/nu-command/src/commands/split_by.rs index 10c93c0d2e..eeb7373491 100644 --- a/crates/nu-command/src/commands/split_by.rs +++ b/crates/nu-command/src/commands/split_by.rs @@ -166,6 +166,6 @@ mod tests { use super::SplitBy; use crate::examples::test as test_examples; - Ok(test_examples(SplitBy {})?) + test_examples(SplitBy {}) } } diff --git a/crates/nu-command/src/commands/str_/capitalize.rs b/crates/nu-command/src/commands/str_/capitalize.rs index 7f6caa5aab..b944df2cc7 100644 --- a/crates/nu-command/src/commands/str_/capitalize.rs +++ b/crates/nu-command/src/commands/str_/capitalize.rs @@ -109,7 +109,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/str_/case/camel_case.rs b/crates/nu-command/src/commands/str_/case/camel_case.rs index c197842e1b..3e4f95ca7b 100644 --- a/crates/nu-command/src/commands/str_/case/camel_case.rs +++ b/crates/nu-command/src/commands/str_/case/camel_case.rs @@ -49,7 +49,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/str_/case/kebab_case.rs b/crates/nu-command/src/commands/str_/case/kebab_case.rs index 1a4b03dd95..3d79777fc0 100644 --- a/crates/nu-command/src/commands/str_/case/kebab_case.rs +++ b/crates/nu-command/src/commands/str_/case/kebab_case.rs @@ -49,7 +49,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/str_/case/pascal_case.rs b/crates/nu-command/src/commands/str_/case/pascal_case.rs index fa43143121..853e0c1128 100644 --- a/crates/nu-command/src/commands/str_/case/pascal_case.rs +++ b/crates/nu-command/src/commands/str_/case/pascal_case.rs @@ -49,7 +49,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/str_/case/screaming_snake_case.rs b/crates/nu-command/src/commands/str_/case/screaming_snake_case.rs index 94a00fbb3a..1d9e467fed 100644 --- a/crates/nu-command/src/commands/str_/case/screaming_snake_case.rs +++ b/crates/nu-command/src/commands/str_/case/screaming_snake_case.rs @@ -49,7 +49,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/str_/case/snake_case.rs b/crates/nu-command/src/commands/str_/case/snake_case.rs index 7c94baadfe..5247123d72 100644 --- a/crates/nu-command/src/commands/str_/case/snake_case.rs +++ b/crates/nu-command/src/commands/str_/case/snake_case.rs @@ -49,7 +49,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/str_/collect.rs b/crates/nu-command/src/commands/str_/collect.rs index 662803399d..e2cb6becc3 100644 --- a/crates/nu-command/src/commands/str_/collect.rs +++ b/crates/nu-command/src/commands/str_/collect.rs @@ -93,6 +93,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/str_/command.rs b/crates/nu-command/src/commands/str_/command.rs index a8688582a1..fb3ebb61e7 100644 --- a/crates/nu-command/src/commands/str_/command.rs +++ b/crates/nu-command/src/commands/str_/command.rs @@ -38,6 +38,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Command {})?) + test_examples(Command {}) } } diff --git a/crates/nu-command/src/commands/str_/contains.rs b/crates/nu-command/src/commands/str_/contains.rs index a8ecf4a40b..6821d444f2 100644 --- a/crates/nu-command/src/commands/str_/contains.rs +++ b/crates/nu-command/src/commands/str_/contains.rs @@ -98,9 +98,9 @@ fn action( match &input.value { UntaggedValue::Primitive(Primitive::String(s)) => { let contains = if insensitive { - s.to_lowercase().find(&pattern.to_lowercase()).is_some() + s.to_lowercase().contains(&pattern.to_lowercase()) } else { - s.find(pattern).is_some() + s.contains(pattern) }; Ok(UntaggedValue::boolean(contains).into_value(tag)) @@ -128,7 +128,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/str_/downcase.rs b/crates/nu-command/src/commands/str_/downcase.rs index 1f6d6f325f..309900bf6b 100644 --- a/crates/nu-command/src/commands/str_/downcase.rs +++ b/crates/nu-command/src/commands/str_/downcase.rs @@ -97,7 +97,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/str_/ends_with.rs b/crates/nu-command/src/commands/str_/ends_with.rs index 3f03f4b27f..65979bcd67 100644 --- a/crates/nu-command/src/commands/str_/ends_with.rs +++ b/crates/nu-command/src/commands/str_/ends_with.rs @@ -102,7 +102,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/str_/find_replace.rs b/crates/nu-command/src/commands/str_/find_replace.rs index 8b6de45f31..32fb9b5ef1 100644 --- a/crates/nu-command/src/commands/str_/find_replace.rs +++ b/crates/nu-command/src/commands/str_/find_replace.rs @@ -146,7 +146,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/str_/from.rs b/crates/nu-command/src/commands/str_/from.rs index 4498a35adb..410bac4959 100644 --- a/crates/nu-command/src/commands/str_/from.rs +++ b/crates/nu-command/src/commands/str_/from.rs @@ -252,6 +252,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/str_/index_of.rs b/crates/nu-command/src/commands/str_/index_of.rs index 5306bd3bc0..5b40d68ea6 100644 --- a/crates/nu-command/src/commands/str_/index_of.rs +++ b/crates/nu-command/src/commands/str_/index_of.rs @@ -244,7 +244,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/str_/length.rs b/crates/nu-command/src/commands/str_/length.rs index a173337450..1e09a70995 100644 --- a/crates/nu-command/src/commands/str_/length.rs +++ b/crates/nu-command/src/commands/str_/length.rs @@ -103,6 +103,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/str_/lpad.rs b/crates/nu-command/src/commands/str_/lpad.rs index da28766b56..e3d97f9c64 100644 --- a/crates/nu-command/src/commands/str_/lpad.rs +++ b/crates/nu-command/src/commands/str_/lpad.rs @@ -154,7 +154,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/str_/reverse.rs b/crates/nu-command/src/commands/str_/reverse.rs index c8b5d87068..c804f2bc1f 100644 --- a/crates/nu-command/src/commands/str_/reverse.rs +++ b/crates/nu-command/src/commands/str_/reverse.rs @@ -92,6 +92,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } } diff --git a/crates/nu-command/src/commands/str_/rpad.rs b/crates/nu-command/src/commands/str_/rpad.rs index 1e7a96b3b4..1afae26f58 100644 --- a/crates/nu-command/src/commands/str_/rpad.rs +++ b/crates/nu-command/src/commands/str_/rpad.rs @@ -154,7 +154,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/str_/starts_with.rs b/crates/nu-command/src/commands/str_/starts_with.rs index 2176d04e26..da7987d4ef 100644 --- a/crates/nu-command/src/commands/str_/starts_with.rs +++ b/crates/nu-command/src/commands/str_/starts_with.rs @@ -102,7 +102,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/str_/substring.rs b/crates/nu-command/src/commands/str_/substring.rs index cfc26714e9..1c1450e1ac 100644 --- a/crates/nu-command/src/commands/str_/substring.rs +++ b/crates/nu-command/src/commands/str_/substring.rs @@ -285,7 +285,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } struct Expectation<'a> { diff --git a/crates/nu-command/src/commands/str_/to_datetime.rs b/crates/nu-command/src/commands/str_/to_datetime.rs index d496284b18..6605c16a6b 100644 --- a/crates/nu-command/src/commands/str_/to_datetime.rs +++ b/crates/nu-command/src/commands/str_/to_datetime.rs @@ -174,7 +174,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/str_/to_decimal.rs b/crates/nu-command/src/commands/str_/to_decimal.rs index ef836d8d57..50d31a944d 100644 --- a/crates/nu-command/src/commands/str_/to_decimal.rs +++ b/crates/nu-command/src/commands/str_/to_decimal.rs @@ -111,7 +111,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/str_/to_integer.rs b/crates/nu-command/src/commands/str_/to_integer.rs index f1b29bfb4d..ea6fa3dcd3 100644 --- a/crates/nu-command/src/commands/str_/to_integer.rs +++ b/crates/nu-command/src/commands/str_/to_integer.rs @@ -166,7 +166,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/str_/trim/mod.rs b/crates/nu-command/src/commands/str_/trim/mod.rs index 352c9a7677..c8531548ff 100644 --- a/crates/nu-command/src/commands/str_/trim/mod.rs +++ b/crates/nu-command/src/commands/str_/trim/mod.rs @@ -103,7 +103,7 @@ where let values: Result, ShellError> = values .iter() .map(|v| -> Result<_, ShellError> { - Ok(action(v, tag.clone(), char_, trim_operation, mode)?) + action(v, tag.clone(), char_, trim_operation, mode) }) .collect(); Ok(UntaggedValue::Table(values?).into_value(tag)) diff --git a/crates/nu-command/src/commands/str_/trim/trim_both_ends.rs b/crates/nu-command/src/commands/str_/trim/trim_both_ends.rs index c18dd8eaf0..df0957dab3 100644 --- a/crates/nu-command/src/commands/str_/trim/trim_both_ends.rs +++ b/crates/nu-command/src/commands/str_/trim/trim_both_ends.rs @@ -69,7 +69,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/str_/trim/trim_left.rs b/crates/nu-command/src/commands/str_/trim/trim_left.rs index 978ddc303b..3526614a6e 100644 --- a/crates/nu-command/src/commands/str_/trim/trim_left.rs +++ b/crates/nu-command/src/commands/str_/trim/trim_left.rs @@ -70,7 +70,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/str_/trim/trim_right.rs b/crates/nu-command/src/commands/str_/trim/trim_right.rs index 513e178822..ba5bf5744b 100644 --- a/crates/nu-command/src/commands/str_/trim/trim_right.rs +++ b/crates/nu-command/src/commands/str_/trim/trim_right.rs @@ -70,7 +70,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/str_/upcase.rs b/crates/nu-command/src/commands/str_/upcase.rs index 18882f5a26..a00bad69c2 100644 --- a/crates/nu-command/src/commands/str_/upcase.rs +++ b/crates/nu-command/src/commands/str_/upcase.rs @@ -97,7 +97,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(SubCommand {})?) + test_examples(SubCommand {}) } #[test] diff --git a/crates/nu-command/src/commands/table/command.rs b/crates/nu-command/src/commands/table/command.rs index 1f3fd75d2e..c1e71228fd 100644 --- a/crates/nu-command/src/commands/table/command.rs +++ b/crates/nu-command/src/commands/table/command.rs @@ -256,6 +256,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Command {})?) + test_examples(Command {}) } } diff --git a/crates/nu-command/src/commands/tags.rs b/crates/nu-command/src/commands/tags.rs index d8c0a360b3..76a236419d 100644 --- a/crates/nu-command/src/commands/tags.rs +++ b/crates/nu-command/src/commands/tags.rs @@ -20,13 +20,12 @@ impl WholeStreamCommand for Tags { } async fn run(&self, args: CommandArgs) -> Result { - tags(args) + Ok(tags(args)) } } -fn tags(args: CommandArgs) -> Result { - Ok(args - .input +fn tags(args: CommandArgs) -> OutputStream { + args.input .map(move |v| { let mut tags = TaggedDictBuilder::new(v.tag()); { @@ -50,7 +49,7 @@ fn tags(args: CommandArgs) -> Result { tags.into_value() }) - .to_output_stream()) + .to_output_stream() } #[cfg(test)] @@ -62,6 +61,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Tags {})?) + test_examples(Tags {}) } } diff --git a/crates/nu-command/src/commands/to.rs b/crates/nu-command/src/commands/to.rs index ee6a4a74ff..4018bd0203 100644 --- a/crates/nu-command/src/commands/to.rs +++ b/crates/nu-command/src/commands/to.rs @@ -36,6 +36,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(To {})?) + test_examples(To {}) } } diff --git a/crates/nu-command/src/commands/to_csv.rs b/crates/nu-command/src/commands/to_csv.rs index 201954dcb9..248872c43d 100644 --- a/crates/nu-command/src/commands/to_csv.rs +++ b/crates/nu-command/src/commands/to_csv.rs @@ -86,6 +86,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(ToCSV {})?) + test_examples(ToCSV {}) } } diff --git a/crates/nu-command/src/commands/to_html.rs b/crates/nu-command/src/commands/to_html.rs index 9aaa1ee091..dd8de05708 100644 --- a/crates/nu-command/src/commands/to_html.rs +++ b/crates/nu-command/src/commands/to_html.rs @@ -758,6 +758,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(ToHTML {})?) + test_examples(ToHTML {}) } } diff --git a/crates/nu-command/src/commands/to_json.rs b/crates/nu-command/src/commands/to_json.rs index 8cebc1b3a2..ae5b227578 100644 --- a/crates/nu-command/src/commands/to_json.rs +++ b/crates/nu-command/src/commands/to_json.rs @@ -262,6 +262,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(ToJSON {})?) + test_examples(ToJSON {}) } } diff --git a/crates/nu-command/src/commands/to_toml.rs b/crates/nu-command/src/commands/to_toml.rs index 613932c8f1..8d3092d0f6 100644 --- a/crates/nu-command/src/commands/to_toml.rs +++ b/crates/nu-command/src/commands/to_toml.rs @@ -195,7 +195,7 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(ToTOML {})?) + test_examples(ToTOML {}) } #[test] diff --git a/crates/nu-command/src/commands/to_tsv.rs b/crates/nu-command/src/commands/to_tsv.rs index 71c39250bd..54ae326f3a 100644 --- a/crates/nu-command/src/commands/to_tsv.rs +++ b/crates/nu-command/src/commands/to_tsv.rs @@ -50,6 +50,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(ToTSV {})?) + test_examples(ToTSV {}) } } diff --git a/crates/nu-command/src/commands/to_url.rs b/crates/nu-command/src/commands/to_url.rs index 0d44afd025..9ff917b797 100644 --- a/crates/nu-command/src/commands/to_url.rs +++ b/crates/nu-command/src/commands/to_url.rs @@ -82,6 +82,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(ToURL {})?) + test_examples(ToURL {}) } } diff --git a/crates/nu-command/src/commands/to_xml.rs b/crates/nu-command/src/commands/to_xml.rs index d3e3a2d0e9..6514bff265 100644 --- a/crates/nu-command/src/commands/to_xml.rs +++ b/crates/nu-command/src/commands/to_xml.rs @@ -195,6 +195,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(ToXML {})?) + test_examples(ToXML {}) } } diff --git a/crates/nu-command/src/commands/to_yaml.rs b/crates/nu-command/src/commands/to_yaml.rs index b445e08f0a..cdfaabd3b5 100644 --- a/crates/nu-command/src/commands/to_yaml.rs +++ b/crates/nu-command/src/commands/to_yaml.rs @@ -170,6 +170,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(ToYAML {})?) + test_examples(ToYAML {}) } } diff --git a/crates/nu-command/src/commands/touch.rs b/crates/nu-command/src/commands/touch.rs index a4db691ebc..4dcce74d91 100644 --- a/crates/nu-command/src/commands/touch.rs +++ b/crates/nu-command/src/commands/touch.rs @@ -79,6 +79,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Touch {})?) + test_examples(Touch {}) } } diff --git a/crates/nu-command/src/commands/uniq.rs b/crates/nu-command/src/commands/uniq.rs index 63f70f9731..6f4ce5d716 100644 --- a/crates/nu-command/src/commands/uniq.rs +++ b/crates/nu-command/src/commands/uniq.rs @@ -127,6 +127,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Uniq {})?) + test_examples(Uniq {}) } } diff --git a/crates/nu-command/src/commands/url_/command.rs b/crates/nu-command/src/commands/url_/command.rs index a42dc498d9..10f851791c 100644 --- a/crates/nu-command/src/commands/url_/command.rs +++ b/crates/nu-command/src/commands/url_/command.rs @@ -35,6 +35,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Url {})?) + test_examples(Url {}) } } diff --git a/crates/nu-command/src/commands/url_/host.rs b/crates/nu-command/src/commands/url_/host.rs index 9e9bd04388..c3d2807077 100644 --- a/crates/nu-command/src/commands/url_/host.rs +++ b/crates/nu-command/src/commands/url_/host.rs @@ -50,6 +50,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(UrlHost {})?) + test_examples(UrlHost {}) } } diff --git a/crates/nu-command/src/commands/url_/path.rs b/crates/nu-command/src/commands/url_/path.rs index 38a4df2187..b31f4f5bf5 100644 --- a/crates/nu-command/src/commands/url_/path.rs +++ b/crates/nu-command/src/commands/url_/path.rs @@ -53,6 +53,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(UrlPath {})?) + test_examples(UrlPath {}) } } diff --git a/crates/nu-command/src/commands/url_/query.rs b/crates/nu-command/src/commands/url_/query.rs index e80df0466e..6378a0661e 100644 --- a/crates/nu-command/src/commands/url_/query.rs +++ b/crates/nu-command/src/commands/url_/query.rs @@ -57,6 +57,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(UrlQuery {})?) + test_examples(UrlQuery {}) } } diff --git a/crates/nu-command/src/commands/url_/scheme.rs b/crates/nu-command/src/commands/url_/scheme.rs index 5fb987771f..da7ed52d55 100644 --- a/crates/nu-command/src/commands/url_/scheme.rs +++ b/crates/nu-command/src/commands/url_/scheme.rs @@ -52,6 +52,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(UrlScheme {})?) + test_examples(UrlScheme {}) } } diff --git a/crates/nu-command/src/commands/version.rs b/crates/nu-command/src/commands/version.rs index 4a39597a96..6217bf2f5e 100644 --- a/crates/nu-command/src/commands/version.rs +++ b/crates/nu-command/src/commands/version.rs @@ -146,9 +146,7 @@ pub fn version(args: CommandArgs) -> Result { } fn features_enabled() -> Vec { - let mut names = vec![]; - - names.push("default".to_string()); + let mut names = vec!["default".to_string()]; #[cfg(feature = "ctrlc")] { @@ -289,6 +287,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Version {})?) + test_examples(Version {}) } } diff --git a/crates/nu-command/src/commands/where_.rs b/crates/nu-command/src/commands/where_.rs index 1a40ba2b2f..13f6362ecc 100644 --- a/crates/nu-command/src/commands/where_.rs +++ b/crates/nu-command/src/commands/where_.rs @@ -134,6 +134,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Where {})?) + test_examples(Where {}) } } diff --git a/crates/nu-command/src/commands/which_.rs b/crates/nu-command/src/commands/which_.rs index 0472901650..2afcadafcd 100644 --- a/crates/nu-command/src/commands/which_.rs +++ b/crates/nu-command/src/commands/which_.rs @@ -249,6 +249,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Which {})?) + test_examples(Which {}) } } diff --git a/crates/nu-command/src/commands/with_env.rs b/crates/nu-command/src/commands/with_env.rs index 32abbadec1..2447b8743b 100644 --- a/crates/nu-command/src/commands/with_env.rs +++ b/crates/nu-command/src/commands/with_env.rs @@ -123,6 +123,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(WithEnv {})?) + test_examples(WithEnv {}) } } diff --git a/crates/nu-command/src/commands/wrap.rs b/crates/nu-command/src/commands/wrap.rs index 7e4682b8ac..c8afab8784 100644 --- a/crates/nu-command/src/commands/wrap.rs +++ b/crates/nu-command/src/commands/wrap.rs @@ -138,6 +138,6 @@ mod tests { fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - Ok(test_examples(Wrap {})?) + test_examples(Wrap {}) } } diff --git a/crates/nu-command/src/prelude.rs b/crates/nu-command/src/prelude.rs index 1e43ab05a7..5d2f005006 100644 --- a/crates/nu-command/src/prelude.rs +++ b/crates/nu-command/src/prelude.rs @@ -74,6 +74,7 @@ pub(crate) use std::future::Future; pub(crate) use std::sync::atomic::{AtomicBool, Ordering}; pub(crate) use std::sync::Arc; +#[allow(clippy::wrong_self_convention)] pub trait FromInputStream { fn from_input_stream(self) -> OutputStream; } @@ -89,6 +90,7 @@ where } } +#[allow(clippy::wrong_self_convention)] pub trait ToOutputStream { fn to_output_stream(self) -> OutputStream; } diff --git a/crates/nu-command/src/utils/arguments.rs b/crates/nu-command/src/utils/arguments.rs index 06998207c3..e5bb2899f1 100644 --- a/crates/nu-command/src/utils/arguments.rs +++ b/crates/nu-command/src/utils/arguments.rs @@ -83,7 +83,7 @@ mod tests { fn arguments_test_2() -> Result<(), Box> { // cmd name [type] let arg1 = string("name"); - let arg2 = table(&vec![string("type")]); + let arg2 = table(&[string("type")]); let expected = vec![ string("name").as_column_path()?.item, diff --git a/crates/nu-data/src/base/shape.rs b/crates/nu-data/src/base/shape.rs index af2137b7cc..41a1674278 100644 --- a/crates/nu-data/src/base/shape.rs +++ b/crates/nu-data/src/base/shape.rs @@ -349,21 +349,21 @@ pub enum Column { Value, } -impl Into for String { - fn into(self) -> Column { - Column::String(self) +impl From for Column { + fn from(x: String) -> Self { + Column::String(x) } } -impl Into for &String { - fn into(self) -> Column { - Column::String(self.clone()) +impl From<&String> for Column { + fn from(x: &String) -> Self { + Column::String(x.clone()) } } -impl Into for &str { - fn into(self) -> Column { - Column::String(self.to_string()) +impl From<&str> for Column { + fn from(x: &str) -> Self { + Column::String(x.to_string()) } } diff --git a/crates/nu-engine/src/filesystem/filesystem_shell.rs b/crates/nu-engine/src/filesystem/filesystem_shell.rs index 64a2710831..ddfe1fbac5 100644 --- a/crates/nu-engine/src/filesystem/filesystem_shell.rs +++ b/crates/nu-engine/src/filesystem/filesystem_shell.rs @@ -707,7 +707,7 @@ impl Shell for FilesystemShell { fn open( &self, - path: &PathBuf, + path: &Path, name: Span, with_encoding: Option<&'static Encoding>, ) -> Result>, ShellError> { @@ -764,7 +764,7 @@ impl Shell for FilesystemShell { fn save( &mut self, - full_path: &PathBuf, + full_path: &Path, save_data: &[u8], name: Span, ) -> Result { @@ -1091,7 +1091,7 @@ pub(crate) fn dir_entry_dict( Ok(dict.into_value()) } -fn path_contains_hidden_folder(path: &PathBuf, folders: &[PathBuf]) -> bool { +fn path_contains_hidden_folder(path: &Path, folders: &[PathBuf]) -> bool { let path_str = path.to_str().expect("failed to read path"); if folders .iter() diff --git a/crates/nu-engine/src/plugin/build_plugin.rs b/crates/nu-engine/src/plugin/build_plugin.rs index 879544dc94..449dde4bd3 100644 --- a/crates/nu-engine/src/plugin/build_plugin.rs +++ b/crates/nu-engine/src/plugin/build_plugin.rs @@ -163,7 +163,6 @@ pub fn scan( None } }).map(|p| p.build()) - .filter_map(Result::ok) .collect::>(); plugins.extend(plugs); } diff --git a/crates/nu-engine/src/plugin/run_plugin.rs b/crates/nu-engine/src/plugin/run_plugin.rs index 89d2773651..8b799daf4c 100644 --- a/crates/nu-engine/src/plugin/run_plugin.rs +++ b/crates/nu-engine/src/plugin/run_plugin.rs @@ -31,10 +31,10 @@ enum PluginCommand { } impl PluginCommand { - fn command(self) -> Result { + fn command(self) -> crate::whole_stream_command::Command { match self { - PluginCommand::Filter(cmd) => Ok(whole_stream_command(cmd)), - PluginCommand::Sink(cmd) => Ok(whole_stream_command(cmd)), + PluginCommand::Filter(cmd) => whole_stream_command(cmd), + PluginCommand::Sink(cmd) => whole_stream_command(cmd), } } } @@ -71,7 +71,7 @@ impl PluginCommandBuilder { } } - pub fn build(&self) -> Result { + pub fn build(&self) -> crate::whole_stream_command::Command { let mode = &self.mode; let name = self.name.clone(); diff --git a/crates/nu-engine/src/shell/help_shell.rs b/crates/nu-engine/src/shell/help_shell.rs index defc21c4dc..ef0fb21e9e 100644 --- a/crates/nu-engine/src/shell/help_shell.rs +++ b/crates/nu-engine/src/shell/help_shell.rs @@ -17,7 +17,7 @@ use nu_stream::OutputStream; use nu_value_ext::ValueExt; use std::collections::VecDeque; use std::ffi::OsStr; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::sync::atomic::AtomicBool; use std::sync::Arc; @@ -225,7 +225,7 @@ impl Shell for HelpShell { fn open( &self, - _path: &PathBuf, + _path: &Path, _name: Span, _with_encoding: Option<&'static Encoding>, ) -> Result>, ShellError> { @@ -236,7 +236,7 @@ impl Shell for HelpShell { fn save( &mut self, - _path: &PathBuf, + _path: &Path, _contents: &[u8], _name: Span, ) -> Result { diff --git a/crates/nu-engine/src/shell/mod.rs b/crates/nu-engine/src/shell/mod.rs index 2b5d367f5b..d747fe392a 100644 --- a/crates/nu-engine/src/shell/mod.rs +++ b/crates/nu-engine/src/shell/mod.rs @@ -7,7 +7,7 @@ use encoding_rs::Encoding; use futures::stream::BoxStream; use nu_errors::ShellError; use nu_source::{Span, Tag}; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::sync::atomic::AtomicBool; use std::sync::Arc; @@ -38,13 +38,13 @@ pub trait Shell: std::fmt::Debug { fn set_path(&mut self, path: String); fn open( &self, - path: &PathBuf, + path: &Path, name: Span, with_encoding: Option<&'static Encoding>, ) -> Result>, ShellError>; fn save( &mut self, - path: &PathBuf, + path: &Path, contents: &[u8], name: Span, ) -> Result; diff --git a/crates/nu-engine/src/shell/shell_manager.rs b/crates/nu-engine/src/shell/shell_manager.rs index 61470c6c62..0abd8f4630 100644 --- a/crates/nu-engine/src/shell/shell_manager.rs +++ b/crates/nu-engine/src/shell/shell_manager.rs @@ -9,7 +9,7 @@ use encoding_rs::Encoding; use nu_errors::ShellError; use nu_source::{Span, Tag}; use parking_lot::Mutex; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::Arc; @@ -71,7 +71,7 @@ impl ShellManager { pub fn open( &self, - full_path: &PathBuf, + full_path: &Path, name: Span, with_encoding: Option<&'static Encoding>, ) -> Result> + Send + 'static, ShellError> @@ -81,7 +81,7 @@ impl ShellManager { pub fn save( &self, - full_path: &PathBuf, + full_path: &Path, save_data: &[u8], name: Span, ) -> Result { diff --git a/crates/nu-engine/src/shell/value_shell.rs b/crates/nu-engine/src/shell/value_shell.rs index 32884c5083..86d31b211f 100644 --- a/crates/nu-engine/src/shell/value_shell.rs +++ b/crates/nu-engine/src/shell/value_shell.rs @@ -235,7 +235,7 @@ impl Shell for ValueShell { fn open( &self, - _path: &PathBuf, + _path: &Path, _name: Span, _with_encoding: Option<&'static Encoding>, ) -> Result>, ShellError> { @@ -246,7 +246,7 @@ impl Shell for ValueShell { fn save( &mut self, - _path: &PathBuf, + _path: &Path, _contents: &[u8], _name: Span, ) -> Result { diff --git a/crates/nu-errors/src/lib.rs b/crates/nu-errors/src/lib.rs index dfe4c8e7e8..39f3b6915c 100644 --- a/crates/nu-errors/src/lib.rs +++ b/crates/nu-errors/src/lib.rs @@ -564,9 +564,7 @@ impl ShellError { diag.message = format!("Missing property (for {})", subpath.item); } else { let subpath = Label::primary(0, subpath.span).with_message(subpath.item); - let mut labels = vec![]; - - labels.push(subpath); + let mut labels = vec![subpath]; if expr.span != Span::unknown() { let expr = Label::primary(0, expr.span).with_message(expr.item); diff --git a/crates/nu-json/src/de.rs b/crates/nu-json/src/de.rs index 10c5a85e2e..ce14bbdf3e 100644 --- a/crates/nu-json/src/de.rs +++ b/crates/nu-json/src/de.rs @@ -688,7 +688,7 @@ where { self.de.parse_object_colon()?; - Ok(de::Deserialize::deserialize(self.de)?) + de::Deserialize::deserialize(self.de) } fn end(&mut self) -> Result<()> { diff --git a/crates/nu-json/src/value.rs b/crates/nu-json/src/value.rs index a5eff0d095..66cd784791 100644 --- a/crates/nu-json/src/value.rs +++ b/crates/nu-json/src/value.rs @@ -1176,7 +1176,7 @@ impl<'a> de::MapVisitor for MapDeserializer<'a> { { let value = self.value.take().expect("value is missing"); self.de.value = Some(value); - Ok(de::Deserialize::deserialize(self.de)?) + de::Deserialize::deserialize(self.de) } fn end(&mut self) -> Result<(), Error> { diff --git a/crates/nu-parser/src/lex/token_group.rs b/crates/nu-parser/src/lex/token_group.rs index b9027ba2ab..99f2b8735b 100644 --- a/crates/nu-parser/src/lex/token_group.rs +++ b/crates/nu-parser/src/lex/token_group.rs @@ -10,12 +10,12 @@ pub struct TokenBuilder { contents: Option>, } -impl Into> for TokenBuilder +impl From> for Vec where T: HasSpan, { - fn into(self) -> Vec { - self.contents.unwrap_or_else(Vec::new) + fn from(x: TokenBuilder) -> Self { + x.contents.unwrap_or_else(Vec::new) } } diff --git a/crates/nu-parser/src/parse.rs b/crates/nu-parser/src/parse.rs index 8652211951..7ba03f3df9 100644 --- a/crates/nu-parser/src/parse.rs +++ b/crates/nu-parser/src/parse.rs @@ -2140,7 +2140,7 @@ pub fn parse( } #[test] -fn unit_parse_byte_units() -> Result<(), ParseError> { +fn unit_parse_byte_units() { struct TestCase { string: String, value: i64, @@ -2275,5 +2275,4 @@ fn unit_parse_byte_units() -> Result<(), ParseError> { ) ); } - Ok(()) } diff --git a/crates/nu-parser/src/parse/def/primitives.rs b/crates/nu-parser/src/parse/def/primitives.rs index a78765c84c..90f681a960 100644 --- a/crates/nu-parser/src/parse/def/primitives.rs +++ b/crates/nu-parser/src/parse/def/primitives.rs @@ -187,7 +187,7 @@ pub fn parse_type_token(type_: &Token) -> (SyntaxShape, Option) { pub(crate) fn parse_rest_name(name_token: &Token) -> Option { return if let TokenContents::Baseline(name) = &name_token.contents { if !name.starts_with("...") { - parse_rest_name_err(name_token) + Some(parse_rest_name_err(name_token)) } else if !name.starts_with("...rest") { Some(ParseError::mismatch( "rest argument name to be 'rest'", @@ -197,13 +197,10 @@ pub(crate) fn parse_rest_name(name_token: &Token) -> Option { None } } else { - parse_rest_name_err(name_token) + Some(parse_rest_name_err(name_token)) }; - fn parse_rest_name_err(token: &Token) -> Option { - Some(ParseError::mismatch( - "...rest", - token_to_spanned_string(token), - )) + fn parse_rest_name_err(token: &Token) -> ParseError { + ParseError::mismatch("...rest", token_to_spanned_string(token)) } } diff --git a/crates/nu-protocol/src/hir.rs b/crates/nu-protocol/src/hir.rs index 1c3a4b44b0..1229131039 100644 --- a/crates/nu-protocol/src/hir.rs +++ b/crates/nu-protocol/src/hir.rs @@ -209,10 +209,8 @@ impl Block { pub fn set_redirect(&mut self, external_redirection: ExternalRedirection) { if let Some(group) = self.block.last_mut() { if let Some(pipeline) = group.pipelines.last_mut() { - if let Some(command) = pipeline.list.last_mut() { - if let ClassifiedCommand::Internal(internal) = command { - internal.args.external_redirection = external_redirection; - } + if let Some(ClassifiedCommand::Internal(internal)) = pipeline.list.last_mut() { + internal.args.external_redirection = external_redirection; } } } diff --git a/crates/nu-protocol/src/type_shape.rs b/crates/nu-protocol/src/type_shape.rs index 4d56e5eb2d..ee7d039edd 100644 --- a/crates/nu-protocol/src/type_shape.rs +++ b/crates/nu-protocol/src/type_shape.rs @@ -389,20 +389,20 @@ pub enum Column { Value, } -impl Into for String { - fn into(self) -> Column { - Column::String(self) +impl From for Column { + fn from(x: String) -> Self { + Column::String(x) } } -impl Into for &String { - fn into(self) -> Column { - Column::String(self.clone()) +impl From<&String> for Column { + fn from(x: &String) -> Self { + Column::String(x.clone()) } } -impl Into for &str { - fn into(self) -> Column { - Column::String(self.to_string()) +impl From<&str> for Column { + fn from(x: &str) -> Self { + Column::String(x.to_string()) } } diff --git a/crates/nu-protocol/src/value.rs b/crates/nu-protocol/src/value.rs index 710b26d070..176404bf53 100644 --- a/crates/nu-protocol/src/value.rs +++ b/crates/nu-protocol/src/value.rs @@ -561,9 +561,9 @@ impl From for UntaggedValue { } /// Convert a borrowed Value into a borrowed UntaggedValue -impl<'a> Into<&'a UntaggedValue> for &'a Value { - fn into(self) -> &'a UntaggedValue { - &self.value +impl<'a> From<&'a Value> for &'a UntaggedValue { + fn from(x: &'a Value) -> Self { + &x.value } } diff --git a/crates/nu-protocol/src/value/serde_bigdecimal.rs b/crates/nu-protocol/src/value/serde_bigdecimal.rs index 38c4e69b93..5d8860affc 100644 --- a/crates/nu-protocol/src/value/serde_bigdecimal.rs +++ b/crates/nu-protocol/src/value/serde_bigdecimal.rs @@ -14,6 +14,6 @@ where D: serde::Deserializer<'de>, { let x: String = serde::Deserialize::deserialize(deserializer)?; - Ok(BigDecimal::parse_bytes(x.as_bytes(), 10) - .ok_or_else(|| serde::de::Error::custom("expected a bigdecimal"))?) + BigDecimal::parse_bytes(x.as_bytes(), 10) + .ok_or_else(|| serde::de::Error::custom("expected a bigdecimal")) } diff --git a/crates/nu-protocol/src/value/serde_bigint.rs b/crates/nu-protocol/src/value/serde_bigint.rs index dabe8c1623..ee455e21f4 100644 --- a/crates/nu-protocol/src/value/serde_bigint.rs +++ b/crates/nu-protocol/src/value/serde_bigint.rs @@ -15,6 +15,6 @@ where { let x: String = serde::Deserialize::deserialize(deserializer)?; - Ok(BigInt::parse_bytes(x.as_bytes(), 10) - .ok_or_else(|| serde::de::Error::custom("expected a bignum"))?) + BigInt::parse_bytes(x.as_bytes(), 10) + .ok_or_else(|| serde::de::Error::custom("expected a bignum")) } diff --git a/crates/nu-source/src/pretty.rs b/crates/nu-source/src/pretty.rs index 494237a694..ff7fed1cce 100644 --- a/crates/nu-source/src/pretty.rs +++ b/crates/nu-source/src/pretty.rs @@ -470,9 +470,9 @@ pub trait PrettyDebug { } } -impl Into for PrettyDebugDocBuilder { - fn into(self) -> DebugDocBuilder { - DebugDocBuilder { inner: self } +impl From for DebugDocBuilder { + fn from(x: PrettyDebugDocBuilder) -> Self { + DebugDocBuilder { inner: x } } } @@ -490,9 +490,9 @@ impl From for PrettyDebugDoc { } } -impl Into for DebugDocBuilder { - fn into(self) -> PrettyDebugDoc { - self.inner.into() +impl From for PrettyDebugDoc { + fn from(x: DebugDocBuilder) -> Self { + x.inner.into() } } diff --git a/crates/nu-stream/src/input.rs b/crates/nu-stream/src/input.rs index fb03d4affb..72eff8fe57 100644 --- a/crates/nu-stream/src/input.rs +++ b/crates/nu-stream/src/input.rs @@ -175,6 +175,7 @@ impl From> for InputStream { } } +#[allow(clippy::clippy::wrong_self_convention)] pub trait ToInputStream { fn to_input_stream(self) -> InputStream; } diff --git a/crates/nu-stream/src/prelude.rs b/crates/nu-stream/src/prelude.rs index 9de98095c6..f0bef4630a 100644 --- a/crates/nu-stream/src/prelude.rs +++ b/crates/nu-stream/src/prelude.rs @@ -76,6 +76,7 @@ pub(crate) use std::sync::Arc; pub(crate) use crate::{InputStream, OutputStream}; +#[allow(clippy::wrong_self_convention)] pub trait ToOutputStream { fn to_output_stream(self) -> OutputStream; } diff --git a/crates/nu_plugin_binaryview/src/binaryview.rs b/crates/nu_plugin_binaryview/src/binaryview.rs index ba3d9a250b..7b37b943aa 100644 --- a/crates/nu_plugin_binaryview/src/binaryview.rs +++ b/crates/nu_plugin_binaryview/src/binaryview.rs @@ -49,7 +49,7 @@ impl RenderContext { self.frame_buffer = vec![(0, 0, 0); self.width * self.height as usize]; } - fn render_to_screen_lores(&mut self) -> Result<(), Box> { + fn render_to_screen_lores(&mut self) { let mut prev_color: Option<(u8, u8, u8)> = None; let mut prev_count = 1; @@ -86,9 +86,8 @@ impl RenderContext { } } outln!("{}", Attribute::Reset); - Ok(()) } - fn render_to_screen_hires(&mut self) -> Result<(), Box> { + fn render_to_screen_hires(&mut self) { let mut prev_fg: Option<(u8, u8, u8)> = None; let mut prev_bg: Option<(u8, u8, u8)> = None; let mut prev_count = 1; @@ -139,9 +138,8 @@ impl RenderContext { } } outln!("{}", Attribute::Reset); - Ok(()) } - pub fn flush(&mut self) -> Result<(), Box> { + pub fn flush(&mut self) { if self.lores_mode { self.render_to_screen_lores() } else { @@ -277,7 +275,7 @@ pub fn view_contents( } } - render_context.flush()?; + render_context.flush(); let _ = std::io::stdout().execute(crossterm::cursor::Show); @@ -353,7 +351,7 @@ pub fn view_contents_interactive( render_context.frame_buffer[count] = (rgb[0], rgb[1], rgb[2]); } - render_context.flush()?; + render_context.flush(); if rawkey.is_pressed(rawkey::KeyCode::Escape) { break 'gameloop; diff --git a/crates/nu_plugin_from_sqlite/src/from_sqlite.rs b/crates/nu_plugin_from_sqlite/src/from_sqlite.rs index 229cd80a47..f713b6f6ba 100644 --- a/crates/nu_plugin_from_sqlite/src/from_sqlite.rs +++ b/crates/nu_plugin_from_sqlite/src/from_sqlite.rs @@ -38,7 +38,7 @@ pub fn convert_sqlite_file_to_nu_value( let mut table_stmt = conn.prepare(&format!("select * from [{}]", table_name))?; let mut table_rows = table_stmt.query(NO_PARAMS)?; while let Some(table_row) = table_rows.next()? { - out.push(convert_sqlite_row_to_nu_value(table_row, tag.clone())?) + out.push(convert_sqlite_row_to_nu_value(table_row, tag.clone())) } meta_dict.insert_value( "table_name".to_string(), @@ -54,10 +54,7 @@ pub fn convert_sqlite_file_to_nu_value( Ok(UntaggedValue::Table(meta_out).into_value(tag)) } -fn convert_sqlite_row_to_nu_value( - row: &Row, - tag: impl Into + Clone, -) -> Result { +fn convert_sqlite_row_to_nu_value(row: &Row, tag: impl Into + Clone) -> Value { let mut collected = TaggedDictBuilder::new(tag.clone()); for (i, c) in row.column_names().iter().enumerate() { collected.insert_value( @@ -65,7 +62,7 @@ fn convert_sqlite_row_to_nu_value( convert_sqlite_value_to_nu_value(row.get_raw(i), tag.clone()), ); } - Ok(collected.into_value()) + collected.into_value() } fn convert_sqlite_value_to_nu_value(value: ValueRef, tag: impl Into + Clone) -> Value { diff --git a/crates/nu_plugin_inc/src/inc.rs b/crates/nu_plugin_inc/src/inc.rs index 2d2a6ab13c..41289cd62a 100644 --- a/crates/nu_plugin_inc/src/inc.rs +++ b/crates/nu_plugin_inc/src/inc.rs @@ -28,12 +28,12 @@ impl Inc { Default::default() } - fn apply(&self, input: &str) -> Result { - let applied = match &self.action { + fn apply(&self, input: &str) -> UntaggedValue { + match &self.action { Some(Action::SemVerAction(act_on)) => { let mut ver = match semver::Version::parse(&input) { Ok(parsed_ver) => parsed_ver, - Err(_) => return Ok(UntaggedValue::string(input.to_string())), + Err(_) => return UntaggedValue::string(input.to_string()), }; match act_on { @@ -48,9 +48,7 @@ impl Inc { Ok(v) => UntaggedValue::string(format!("{}", v + 1)), Err(_) => UntaggedValue::string(input), }, - }; - - Ok(applied) + } } pub fn for_semver(&mut self, part: SemVerAction) { @@ -82,7 +80,7 @@ impl Inc { Ok(UntaggedValue::filesize(b + 1_u64).into_value(value.tag())) } UntaggedValue::Primitive(Primitive::String(ref s)) => { - Ok(self.apply(&s)?.into_value(value.tag())) + Ok(self.apply(&s).into_value(value.tag())) } UntaggedValue::Table(values) => { if values.len() == 1 { @@ -153,27 +151,24 @@ mod tests { use nu_test_support::value::string; #[test] - fn major() -> Result<(), Box> { + fn major() { let mut inc = Inc::new(); inc.for_semver(SemVerAction::Major); - assert_eq!(inc.apply("0.1.3")?, string("1.0.0").value); - Ok(()) + assert_eq!(inc.apply("0.1.3"), string("1.0.0").value); } #[test] - fn minor() -> Result<(), Box> { + fn minor() { let mut inc = Inc::new(); inc.for_semver(SemVerAction::Minor); - assert_eq!(inc.apply("0.1.3")?, string("0.2.0").value); - Ok(()) + assert_eq!(inc.apply("0.1.3"), string("0.2.0").value); } #[test] - fn patch() -> Result<(), Box> { + fn patch() { let mut inc = Inc::new(); inc.for_semver(SemVerAction::Patch); - assert_eq!(inc.apply("0.1.3")?, string("0.1.4").value); - Ok(()) + assert_eq!(inc.apply("0.1.3"), string("0.1.4").value); } } } diff --git a/crates/nu_plugin_selector/src/nu/mod.rs b/crates/nu_plugin_selector/src/nu/mod.rs index 25bd08971f..4999aa429c 100644 --- a/crates/nu_plugin_selector/src/nu/mod.rs +++ b/crates/nu_plugin_selector/src/nu/mod.rs @@ -39,7 +39,7 @@ impl Plugin for Selector { value: UntaggedValue::Primitive(Primitive::String(s)), .. } => Ok( - begin_selector_query(s, (*self.query).tagged(&self.tag), self.as_html)? + begin_selector_query(s, (*self.query).tagged(&self.tag), self.as_html) .into_iter() .map(ReturnSuccess::value) .collect(), diff --git a/crates/nu_plugin_selector/src/selector.rs b/crates/nu_plugin_selector/src/selector.rs index ad313eea7c..6cd8b4566a 100644 --- a/crates/nu_plugin_selector/src/selector.rs +++ b/crates/nu_plugin_selector/src/selector.rs @@ -1,5 +1,4 @@ use nipper::Document; -use nu_errors::ShellError; use nu_protocol::{value::StringExt, Value}; use nu_source::{Tag, Tagged}; @@ -25,11 +24,7 @@ impl Default for Selector { } } -pub fn begin_selector_query( - input: String, - query: Tagged<&str>, - as_html: bool, -) -> Result, ShellError> { +pub fn begin_selector_query(input: String, query: Tagged<&str>, as_html: bool) -> Vec { execute_selector_query(input, query.item.to_string(), query.tag(), as_html) } @@ -38,7 +33,7 @@ fn execute_selector_query( query_string: String, tag: impl Into, as_html: bool, -) -> Result, ShellError> { +) -> Vec { let _tag = tag.into(); let mut ret = vec![]; let doc = Document::from(&input_string); @@ -64,28 +59,25 @@ fn execute_selector_query( ret.push(athing.text().to_string().to_string_value_create_tag()); }); } - Ok(ret) + ret } #[cfg(test)] mod tests { use nipper::Document; - use nu_errors::ShellError; #[test] - fn create_document_from_string() -> Result<(), ShellError> { + fn create_document_from_string() { let html = r#"
"#; let document = Document::from(html); let shouldbe = r#"
"#; assert_eq!(shouldbe.to_string(), document.html().to_string()); - - Ok(()) } #[test] - fn modify_html_document() -> Result<(), ShellError> { + fn modify_html_document() { let html = r#"
"#; let document = Document::from(html); let mut input = document.select(r#"div[name="foo"]"#); @@ -96,8 +88,6 @@ mod tests { let actual = input.attr("value").unwrap().to_string(); assert_eq!(shouldbe, actual); - - Ok(()) } // #[test]