diff --git a/crates/nu-cli/src/commands/autoview/options.rs b/crates/nu-cli/src/commands/autoview/options.rs index dfb8740b0..ad6aa5fca 100644 --- a/crates/nu-cli/src/commands/autoview/options.rs +++ b/crates/nu-cli/src/commands/autoview/options.rs @@ -10,25 +10,16 @@ pub enum AutoPivotMode { impl AutoPivotMode { pub fn is_auto(&self) -> bool { - match &self { - AutoPivotMode::Auto => true, - _ => false, - } + matches!(self, AutoPivotMode::Auto) } pub fn is_always(&self) -> bool { - match &self { - AutoPivotMode::Always => true, - _ => false, - } + matches!(self, AutoPivotMode::Always) } #[allow(unused)] pub fn is_never(&self) -> bool { - match &self { - AutoPivotMode::Never => true, - _ => false, - } + matches!(self, AutoPivotMode::Never) } } diff --git a/crates/nu-cli/src/commands/from_ssv.rs b/crates/nu-cli/src/commands/from_ssv.rs index 8849f41ad..9d88725ea 100644 --- a/crates/nu-cli/src/commands/from_ssv.rs +++ b/crates/nu-cli/src/commands/from_ssv.rs @@ -135,7 +135,7 @@ fn parse_aligned_columns<'a>( .flat_map(|s| find_indices(*s)) .collect::>(); - indices.sort(); + indices.sort_unstable(); indices.dedup(); let headers: Vec<(String, usize)> = indices diff --git a/crates/nu-cli/src/commands/move_/column.rs b/crates/nu-cli/src/commands/move_/column.rs index 6457a39b0..4151098a5 100644 --- a/crates/nu-cli/src/commands/move_/column.rs +++ b/crates/nu-cli/src/commands/move_/column.rs @@ -218,17 +218,13 @@ fn move_after( )); }; - let columns_moved = table - .data_descriptors() - .into_iter() - .map(|name| { - if columns.contains(&name) { - None - } else { - Some(name) - } - }) - .collect::>(); + let columns_moved = table.data_descriptors().into_iter().map(|name| { + if columns.contains(&name) { + None + } else { + Some(name) + } + }); let mut reordered_columns = vec![]; let mut insert = false; @@ -281,17 +277,13 @@ fn move_before( )); }; - let columns_moved = table - .data_descriptors() - .into_iter() - .map(|name| { - if columns.contains(&name) { - None - } else { - Some(name) - } - }) - .collect::>(); + let columns_moved = table.data_descriptors().into_iter().map(|name| { + if columns.contains(&name) { + None + } else { + Some(name) + } + }); let mut reordered_columns = vec![]; let mut inserted = false; diff --git a/crates/nu-cli/src/completion/engine.rs b/crates/nu-cli/src/completion/engine.rs index a6949298e..2f15ee9b4 100644 --- a/crates/nu-cli/src/completion/engine.rs +++ b/crates/nu-cli/src/completion/engine.rs @@ -266,11 +266,11 @@ mod tests { impl SignatureRegistry for VecRegistry { fn has(&self, name: &str) -> bool { - self.0.iter().any(|v| &v.name == name) + self.0.iter().any(|v| v.name == name) } fn get(&self, name: &str) -> Option { - self.0.iter().find(|v| &v.name == name).map(Clone::clone) + self.0.iter().find(|v| v.name == name).map(Clone::clone) } fn clone_box(&self) -> Box { diff --git a/crates/nu-cli/src/examples.rs b/crates/nu-cli/src/examples.rs index 3d893b177..83bd6bacf 100644 --- a/crates/nu-cli/src/examples.rs +++ b/crates/nu-cli/src/examples.rs @@ -53,15 +53,8 @@ pub fn test_examples(cmd: Command) -> Result<(), ShellError> { if let Some(expected) = &sample_pipeline.result { let result = block_on(evaluate_block(block, &mut ctx))?; - ctx.with_errors(|reasons| { - reasons - .iter() - .cloned() - .take(1) - .next() - .and_then(|err| Some(err)) - }) - .map_or(Ok(()), |reason| Err(reason))?; + ctx.with_errors(|reasons| reasons.iter().cloned().take(1).next()) + .map_or(Ok(()), Err)?; if expected.len() != result.len() { let rows_returned = @@ -115,15 +108,8 @@ pub fn test(cmd: impl WholeStreamCommand + 'static) -> Result<(), ShellError> { if let Some(expected) = &sample_pipeline.result { let result = block_on(evaluate_block(block, &mut ctx))?; - ctx.with_errors(|reasons| { - reasons - .iter() - .cloned() - .take(1) - .next() - .and_then(|err| Some(err)) - }) - .map_or(Ok(()), |reason| Err(reason))?; + ctx.with_errors(|reasons| reasons.iter().cloned().take(1).next()) + .map_or(Ok(()), Err)?; if expected.len() != result.len() { let rows_returned = @@ -180,15 +166,8 @@ pub fn test_anchors(cmd: Command) -> Result<(), ShellError> { let block = parse_line(&pipeline_with_anchor, &mut ctx)?; let result = block_on(evaluate_block(block, &mut ctx))?; - ctx.with_errors(|reasons| { - reasons - .iter() - .cloned() - .take(1) - .next() - .and_then(|err| Some(err)) - }) - .map_or(Ok(()), |reason| Err(reason))?; + ctx.with_errors(|reasons| reasons.iter().cloned().take(1).next()) + .map_or(Ok(()), Err)?; for actual in result.iter() { if !is_anchor_carried(actual, mock_path()) { @@ -366,7 +345,7 @@ impl WholeStreamCommand for MockEcho { match i.as_string() { Ok(s) => OutputStream::one(Ok(ReturnSuccess::Value(Value { value: UntaggedValue::Primitive(Primitive::String(s)), - tag: base_value.tag.clone(), + tag: base_value.tag, }))), _ => match i { Value { @@ -384,7 +363,7 @@ impl WholeStreamCommand for MockEcho { .to_output_stream(), _ => OutputStream::one(Ok(ReturnSuccess::Value(Value { value: i.value.clone(), - tag: base_value.tag.clone(), + tag: base_value.tag, }))), }, } diff --git a/crates/nu-cli/tests/commands/into_int.rs b/crates/nu-cli/tests/commands/into_int.rs index 47dc71c38..5bf6a7be7 100644 --- a/crates/nu-cli/tests/commands/into_int.rs +++ b/crates/nu-cli/tests/commands/into_int.rs @@ -9,7 +9,7 @@ fn into_int_filesize() { "# )); - assert!(actual.out.contains("1")); + assert!(actual.out.contains('1')); } #[test] @@ -21,5 +21,5 @@ fn into_int_int() { "# )); - assert!(actual.out.contains("1")); + assert!(actual.out.contains('1')); } diff --git a/crates/nu-cli/tests/commands/keep/mod.rs b/crates/nu-cli/tests/commands/keep/mod.rs index 3202079b1..a267c2352 100644 --- a/crates/nu-cli/tests/commands/keep/mod.rs +++ b/crates/nu-cli/tests/commands/keep/mod.rs @@ -1,3 +1,3 @@ -mod keep; +mod rows; mod until; mod while_; diff --git a/crates/nu-cli/tests/commands/keep/keep.rs b/crates/nu-cli/tests/commands/keep/rows.rs similarity index 100% rename from crates/nu-cli/tests/commands/keep/keep.rs rename to crates/nu-cli/tests/commands/keep/rows.rs diff --git a/crates/nu-cli/tests/commands/random/integer.rs b/crates/nu-cli/tests/commands/random/integer.rs index c4302d860..80cc8f5a2 100644 --- a/crates/nu-cli/tests/commands/random/integer.rs +++ b/crates/nu-cli/tests/commands/random/integer.rs @@ -33,5 +33,5 @@ fn generates_0() { "# )); - assert!(actual.out.contains("0")); + assert!(actual.out.contains('0')); }