From 7e66aca18e3e9c4e0a58a7ec76805d911ba77966 Mon Sep 17 00:00:00 2001 From: Michael Angerman Date: Tue, 26 Oct 2021 11:29:00 -0700 Subject: [PATCH 01/10] going to have to figure out how to clone input or some other solution --- crates/nu-command/src/default_context.rs | 1 + crates/nu-command/src/filters/last.rs | 78 ++++++++++++++++++++++++ crates/nu-command/src/filters/mod.rs | 2 + 3 files changed, 81 insertions(+) create mode 100644 crates/nu-command/src/filters/last.rs diff --git a/crates/nu-command/src/default_context.rs b/crates/nu-command/src/default_context.rs index f7a49007c0..626a7ab32a 100644 --- a/crates/nu-command/src/default_context.rs +++ b/crates/nu-command/src/default_context.rs @@ -43,6 +43,7 @@ pub fn create_default_context() -> EngineState { IntoBinary, IntoFilesize, IntoInt, + Last, Length, Let, LetEnv, diff --git a/crates/nu-command/src/filters/last.rs b/crates/nu-command/src/filters/last.rs new file mode 100644 index 0000000000..b626369625 --- /dev/null +++ b/crates/nu-command/src/filters/last.rs @@ -0,0 +1,78 @@ +use nu_engine::CallExt; + +use nu_protocol::ast::Call; +use nu_protocol::engine::{Command, EngineState, Stack}; +use nu_protocol::{PipelineData, ShellError, Signature, SyntaxShape, Value}; +//use nu_protocol::{IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Value}; + +#[derive(Clone)] +pub struct Last; + +impl Command for Last { + fn name(&self) -> &str { + "last" + } + + fn signature(&self) -> Signature { + Signature::build("last").optional( + "rows", + SyntaxShape::Int, + "starting from the back, the number of rows to return", + ) + } + + fn usage(&self) -> &str { + "Show only the last number of rows." + } + + fn run( + &self, + engine_state: &EngineState, + stack: &mut Stack, + call: &Call, + input: PipelineData, + ) -> Result { + let rows: Option = call.opt(engine_state, stack, 0)?; + + let vlength = length(input)?; + dbg!(vlength); + + let end_rows_desired = if let Some(quantity) = rows { + quantity + } else { + 1 + }; + + let beginning_rows_to_skip = if end_rows_desired < vlength { + vlength - end_rows_desired + } else { + 0 + }; + + dbg!(beginning_rows_to_skip); + + // let iter = v.into_iter().skip(beginning_rows_to_skip); + + //dbg!(input.clone()); + /* + match input { + PipelineData::Stream(stream) => Ok(stream.into_pipeline_data()), + PipelineData::Value(Value::List { vals, .. }) => { + Ok(vals.into_iter().into_pipeline_data()) + } + _ => { + dbg!("Fall to the bottom"); + Ok(PipelineData::Value(Value::Nothing { span: call.head })) + } + } + */ + Ok(PipelineData::Value(Value::Nothing { span: call.head })) + } +} + +fn length(input: PipelineData) -> Result { + match input { + PipelineData::Value(Value::Nothing { .. }) => Ok(1), + _ => Ok(input.into_iter().count() as i64), + } +} diff --git a/crates/nu-command/src/filters/mod.rs b/crates/nu-command/src/filters/mod.rs index bb87c7944b..595fe396cd 100644 --- a/crates/nu-command/src/filters/mod.rs +++ b/crates/nu-command/src/filters/mod.rs @@ -1,5 +1,6 @@ mod each; mod get; +mod last; mod length; mod lines; mod par_each; @@ -9,6 +10,7 @@ mod wrap; pub use each::Each; pub use get::Get; +pub use last::Last; pub use length::Length; pub use lines::Lines; pub use par_each::ParEach; From 3625324bada2199cc3dd05cc3f70510c907c3a74 Mon Sep 17 00:00:00 2001 From: Michael Angerman Date: Tue, 26 Oct 2021 11:46:03 -0700 Subject: [PATCH 02/10] last is working also with the hard coded length, need to figure out how to get the length of the input --- crates/nu-command/src/filters/last.rs | 70 ++++++++++++++------------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/crates/nu-command/src/filters/last.rs b/crates/nu-command/src/filters/last.rs index b626369625..f9ed664feb 100644 --- a/crates/nu-command/src/filters/last.rs +++ b/crates/nu-command/src/filters/last.rs @@ -2,8 +2,9 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{PipelineData, ShellError, Signature, SyntaxShape, Value}; -//use nu_protocol::{IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Value}; +use nu_protocol::{IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Value}; + +use std::convert::TryInto; #[derive(Clone)] pub struct Last; @@ -34,39 +35,42 @@ impl Command for Last { ) -> Result { let rows: Option = call.opt(engine_state, stack, 0)?; - let vlength = length(input)?; - dbg!(vlength); - - let end_rows_desired = if let Some(quantity) = rows { - quantity - } else { - 1 - }; - - let beginning_rows_to_skip = if end_rows_desired < vlength { - vlength - end_rows_desired - } else { - 0 - }; - - dbg!(beginning_rows_to_skip); - - // let iter = v.into_iter().skip(beginning_rows_to_skip); - - //dbg!(input.clone()); /* - match input { - PipelineData::Stream(stream) => Ok(stream.into_pipeline_data()), - PipelineData::Value(Value::List { vals, .. }) => { - Ok(vals.into_iter().into_pipeline_data()) - } - _ => { - dbg!("Fall to the bottom"); - Ok(PipelineData::Value(Value::Nothing { span: call.head })) - } - } + let vlength = length(input)?; + dbg!(vlength); + + let end_rows_desired = if let Some(quantity) = rows { + quantity + } else { + 1 + }; + + let beginning_rows_to_skip = if end_rows_desired < vlength { + vlength - end_rows_desired + } else { + 0 + }; + + dbg!(beginning_rows_to_skip); */ - Ok(PipelineData::Value(Value::Nothing { span: call.head })) + + let beginning_rows_to_skip = 2; + + match input { + PipelineData::Stream(stream) => Ok(stream + .skip(beginning_rows_to_skip.try_into().unwrap()) + .into_pipeline_data()), + PipelineData::Value(Value::List { vals, .. }) => Ok(vals + .into_iter() + .skip(beginning_rows_to_skip.try_into().unwrap()) + .into_pipeline_data()), + _ => { + dbg!("Fall to the bottom"); + Ok(PipelineData::Value(Value::Nothing { span: call.head })) + } + } + + // Ok(PipelineData::Value(Value::Nothing { span: call.head })) } } From ca7ff37697e987ff648225a770482a966cb2e678 Mon Sep 17 00:00:00 2001 From: Michael Angerman Date: Tue, 26 Oct 2021 13:06:26 -0700 Subject: [PATCH 03/10] add in dbg info so I can see what is being matched on --- crates/nu-command/src/filters/last.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/crates/nu-command/src/filters/last.rs b/crates/nu-command/src/filters/last.rs index f9ed664feb..75ffd6fec1 100644 --- a/crates/nu-command/src/filters/last.rs +++ b/crates/nu-command/src/filters/last.rs @@ -57,13 +57,19 @@ impl Command for Last { let beginning_rows_to_skip = 2; match input { - PipelineData::Stream(stream) => Ok(stream - .skip(beginning_rows_to_skip.try_into().unwrap()) - .into_pipeline_data()), - PipelineData::Value(Value::List { vals, .. }) => Ok(vals - .into_iter() - .skip(beginning_rows_to_skip.try_into().unwrap()) - .into_pipeline_data()), + PipelineData::Stream(stream) => { + dbg!("Stream"); + Ok(stream + .skip(beginning_rows_to_skip.try_into().unwrap()) + .into_pipeline_data()) + } + PipelineData::Value(Value::List { vals, .. }) => { + dbg!("Value"); + Ok(vals + .into_iter() + .skip(beginning_rows_to_skip.try_into().unwrap()) + .into_pipeline_data()) + } _ => { dbg!("Fall to the bottom"); Ok(PipelineData::Value(Value::Nothing { span: call.head })) From 95628bef161ea612fa847244f79d453937616e7b Mon Sep 17 00:00:00 2001 From: Michael Angerman Date: Tue, 26 Oct 2021 13:45:10 -0700 Subject: [PATCH 04/10] sending off for JT to review --- crates/nu-command/src/filters/last.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/nu-command/src/filters/last.rs b/crates/nu-command/src/filters/last.rs index 75ffd6fec1..c5b4f98640 100644 --- a/crates/nu-command/src/filters/last.rs +++ b/crates/nu-command/src/filters/last.rs @@ -35,6 +35,11 @@ impl Command for Last { ) -> Result { let rows: Option = call.opt(engine_state, stack, 0)?; + // This code works fine and does the correct + // calculation of the beginning_rows_to_skip + // but it can not currently be used because + // I am not able to clone the input + /* let vlength = length(input)?; dbg!(vlength); @@ -54,6 +59,17 @@ impl Command for Last { dbg!(beginning_rows_to_skip); */ + // This code works fine if I am able to get this value + // So for now I am hard coding this number + + // The above code successfully calculates this number + // and it all works if I was able to clone the input + + // it seems being able to + // clone the input is important + + // As we were able to do that prior to your changes... + let beginning_rows_to_skip = 2; match input { From 6d6b8509115fc37290cd77e5765d5d4be56a6a14 Mon Sep 17 00:00:00 2001 From: Michael Angerman Date: Tue, 26 Oct 2021 20:48:31 -0700 Subject: [PATCH 05/10] switched to a working function called rows_to_skip --- crates/nu-command/src/filters/last.rs | 75 ++++++++++++++++----------- 1 file changed, 45 insertions(+), 30 deletions(-) diff --git a/crates/nu-command/src/filters/last.rs b/crates/nu-command/src/filters/last.rs index c5b4f98640..911d6897a6 100644 --- a/crates/nu-command/src/filters/last.rs +++ b/crates/nu-command/src/filters/last.rs @@ -2,9 +2,10 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Value}; +use nu_protocol::{PipelineData, ShellError, Signature, SyntaxShape, Value}; -use std::convert::TryInto; +//use nu_protocol::{IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Value}; +//use std::convert::TryInto; #[derive(Clone)] pub struct Last; @@ -35,6 +36,12 @@ impl Command for Last { ) -> Result { let rows: Option = call.opt(engine_state, stack, 0)?; + let iter_count: i64 = input.into_iter().count() as i64; + + let beginning_rows_to_skip = rows_to_skip(iter_count, rows); + + dbg!(beginning_rows_to_skip); + // This code works fine and does the correct // calculation of the beginning_rows_to_skip // but it can not currently be used because @@ -56,7 +63,7 @@ impl Command for Last { 0 }; - dbg!(beginning_rows_to_skip); + */ // This code works fine if I am able to get this value @@ -70,35 +77,43 @@ impl Command for Last { // As we were able to do that prior to your changes... - let beginning_rows_to_skip = 2; + /* + let beginning_rows_to_skip = 2; - match input { - PipelineData::Stream(stream) => { - dbg!("Stream"); - Ok(stream - .skip(beginning_rows_to_skip.try_into().unwrap()) - .into_pipeline_data()) - } - PipelineData::Value(Value::List { vals, .. }) => { - dbg!("Value"); - Ok(vals - .into_iter() - .skip(beginning_rows_to_skip.try_into().unwrap()) - .into_pipeline_data()) - } - _ => { - dbg!("Fall to the bottom"); - Ok(PipelineData::Value(Value::Nothing { span: call.head })) - } - } - - // Ok(PipelineData::Value(Value::Nothing { span: call.head })) + match input { + PipelineData::Stream(stream) => { + dbg!("Stream"); + Ok(stream + .skip(beginning_rows_to_skip.try_into().unwrap()) + .into_pipeline_data()) + } + PipelineData::Value(Value::List { vals, .. }) => { + dbg!("Value"); + Ok(vals + .into_iter() + .skip(beginning_rows_to_skip.try_into().unwrap()) + .into_pipeline_data()) + } + _ => { + dbg!("Fall to the bottom"); + Ok(PipelineData::Value(Value::Nothing { span: call.head })) + } + } + */ + Ok(PipelineData::Value(Value::Nothing { span: call.head })) } } -fn length(input: PipelineData) -> Result { - match input { - PipelineData::Value(Value::Nothing { .. }) => Ok(1), - _ => Ok(input.into_iter().count() as i64), - } +fn rows_to_skip(count: i64, rows: Option) -> i64 { + let end_rows_desired = if let Some(quantity) = rows { + quantity + } else { + 1 + }; + + if end_rows_desired < count { + return count - end_rows_desired; + } else { + return 0; + }; } From 5d62f1a9c1660547401c84f7fcc914c812f50c73 Mon Sep 17 00:00:00 2001 From: Michael Angerman Date: Tue, 26 Oct 2021 21:04:48 -0700 Subject: [PATCH 06/10] compile error to show issue --- crates/nu-command/src/filters/last.rs | 87 +++++++-------------------- 1 file changed, 23 insertions(+), 64 deletions(-) diff --git a/crates/nu-command/src/filters/last.rs b/crates/nu-command/src/filters/last.rs index 911d6897a6..afc0c5ad28 100644 --- a/crates/nu-command/src/filters/last.rs +++ b/crates/nu-command/src/filters/last.rs @@ -2,10 +2,8 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{PipelineData, ShellError, Signature, SyntaxShape, Value}; - -//use nu_protocol::{IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Value}; -//use std::convert::TryInto; +use nu_protocol::{IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Value}; +use std::convert::TryInto; #[derive(Clone)] pub struct Last; @@ -35,72 +33,33 @@ impl Command for Last { input: PipelineData, ) -> Result { let rows: Option = call.opt(engine_state, stack, 0)?; - let iter_count: i64 = input.into_iter().count() as i64; - let beginning_rows_to_skip = rows_to_skip(iter_count, rows); - dbg!(beginning_rows_to_skip); - // This code works fine and does the correct - // calculation of the beginning_rows_to_skip - // but it can not currently be used because - // I am not able to clone the input + // let beginning_rows_to_skip = 3; - /* - let vlength = length(input)?; - dbg!(vlength); + match input { + PipelineData::Stream(stream) => { + dbg!("Stream"); + Ok(stream + .skip(beginning_rows_to_skip.try_into().unwrap()) + .into_pipeline_data()) + } + PipelineData::Value(Value::List { vals, .. }) => { + dbg!("Value"); + Ok(vals + .into_iter() + .skip(beginning_rows_to_skip.try_into().unwrap()) + .into_pipeline_data()) + } + _ => { + dbg!("Fall to the bottom"); + Ok(PipelineData::Value(Value::Nothing { span: call.head })) + } + } - let end_rows_desired = if let Some(quantity) = rows { - quantity - } else { - 1 - }; - - let beginning_rows_to_skip = if end_rows_desired < vlength { - vlength - end_rows_desired - } else { - 0 - }; - - - */ - - // This code works fine if I am able to get this value - // So for now I am hard coding this number - - // The above code successfully calculates this number - // and it all works if I was able to clone the input - - // it seems being able to - // clone the input is important - - // As we were able to do that prior to your changes... - - /* - let beginning_rows_to_skip = 2; - - match input { - PipelineData::Stream(stream) => { - dbg!("Stream"); - Ok(stream - .skip(beginning_rows_to_skip.try_into().unwrap()) - .into_pipeline_data()) - } - PipelineData::Value(Value::List { vals, .. }) => { - dbg!("Value"); - Ok(vals - .into_iter() - .skip(beginning_rows_to_skip.try_into().unwrap()) - .into_pipeline_data()) - } - _ => { - dbg!("Fall to the bottom"); - Ok(PipelineData::Value(Value::Nothing { span: call.head })) - } - } - */ - Ok(PipelineData::Value(Value::Nothing { span: call.head })) + // Ok(PipelineData::Value(Value::Nothing { span: call.head })) } } From 656e86a7ca8f28e45329ae0525e04bca942de36d Mon Sep 17 00:00:00 2001 From: Michael Angerman Date: Wed, 27 Oct 2021 07:19:33 -0700 Subject: [PATCH 07/10] got it working by turning it into a vec --- crates/nu-command/src/filters/last.rs | 77 ++++++++++++++++++--------- 1 file changed, 53 insertions(+), 24 deletions(-) diff --git a/crates/nu-command/src/filters/last.rs b/crates/nu-command/src/filters/last.rs index afc0c5ad28..e2b9eefe97 100644 --- a/crates/nu-command/src/filters/last.rs +++ b/crates/nu-command/src/filters/last.rs @@ -2,7 +2,7 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Value}; +use nu_protocol::{IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape}; use std::convert::TryInto; #[derive(Clone)] @@ -33,33 +33,62 @@ impl Command for Last { input: PipelineData, ) -> Result { let rows: Option = call.opt(engine_state, stack, 0)?; - let iter_count: i64 = input.into_iter().count() as i64; - let beginning_rows_to_skip = rows_to_skip(iter_count, rows); - dbg!(beginning_rows_to_skip); + let v: Vec<_> = input.into_iter().collect(); + let vlen: i64 = v.len() as i64; + let beginning_rows_to_skip = rows_to_skip(vlen, rows); + /* + let end_rows_desired = if let Some(quantity) = rows { + quantity + } else { + 1 + }; + + let beginning_rows_to_skip = if end_rows_desired < v.len() { + v.len() - end_rows_desired + } else { + 0 + }; + */ + + let iter = v + .into_iter() + .skip(beginning_rows_to_skip.try_into().unwrap()); + + //let iter = v.into_iter().skip(beginning_rows_to_skip); + + /* + let iter_count: i64 = input.into_iter().count() as i64; + let beginning_rows_to_skip = rows_to_skip(iter_count, rows); + dbg!(beginning_rows_to_skip); + */ // let beginning_rows_to_skip = 3; - match input { - PipelineData::Stream(stream) => { - dbg!("Stream"); - Ok(stream - .skip(beginning_rows_to_skip.try_into().unwrap()) - .into_pipeline_data()) - } - PipelineData::Value(Value::List { vals, .. }) => { - dbg!("Value"); - Ok(vals - .into_iter() - .skip(beginning_rows_to_skip.try_into().unwrap()) - .into_pipeline_data()) - } - _ => { - dbg!("Fall to the bottom"); - Ok(PipelineData::Value(Value::Nothing { span: call.head })) - } - } + /* + match input { + PipelineData::Stream(stream) => { + dbg!("Stream"); + Ok(stream + .skip(beginning_rows_to_skip.try_into().unwrap()) + .into_pipeline_data()) + } + PipelineData::Value(Value::List { vals, .. }) => { + dbg!("Value"); + Ok(vals + .into_iter() + .skip(beginning_rows_to_skip.try_into().unwrap()) + .into_pipeline_data()) + } + _ => { + dbg!("Fall to the bottom"); + Ok(PipelineData::Value(Value::Nothing { span: call.head })) + } + } + */ - // Ok(PipelineData::Value(Value::Nothing { span: call.head })) + Ok(iter.into_pipeline_data()) + + // Ok(PipelineData::Value(Value::Nothing { span: call.head })) } } From 4b31fe1924ba209a7c42057bdba8e29028563d45 Mon Sep 17 00:00:00 2001 From: Michael Angerman Date: Wed, 27 Oct 2021 07:25:30 -0700 Subject: [PATCH 08/10] code cleanup --- crates/nu-command/src/filters/last.rs | 47 --------------------------- 1 file changed, 47 deletions(-) diff --git a/crates/nu-command/src/filters/last.rs b/crates/nu-command/src/filters/last.rs index e2b9eefe97..77cad9604c 100644 --- a/crates/nu-command/src/filters/last.rs +++ b/crates/nu-command/src/filters/last.rs @@ -37,58 +37,11 @@ impl Command for Last { let vlen: i64 = v.len() as i64; let beginning_rows_to_skip = rows_to_skip(vlen, rows); - /* - let end_rows_desired = if let Some(quantity) = rows { - quantity - } else { - 1 - }; - - let beginning_rows_to_skip = if end_rows_desired < v.len() { - v.len() - end_rows_desired - } else { - 0 - }; - */ - let iter = v .into_iter() .skip(beginning_rows_to_skip.try_into().unwrap()); - //let iter = v.into_iter().skip(beginning_rows_to_skip); - - /* - let iter_count: i64 = input.into_iter().count() as i64; - let beginning_rows_to_skip = rows_to_skip(iter_count, rows); - dbg!(beginning_rows_to_skip); - */ - // let beginning_rows_to_skip = 3; - - /* - match input { - PipelineData::Stream(stream) => { - dbg!("Stream"); - Ok(stream - .skip(beginning_rows_to_skip.try_into().unwrap()) - .into_pipeline_data()) - } - PipelineData::Value(Value::List { vals, .. }) => { - dbg!("Value"); - Ok(vals - .into_iter() - .skip(beginning_rows_to_skip.try_into().unwrap()) - .into_pipeline_data()) - } - _ => { - dbg!("Fall to the bottom"); - Ok(PipelineData::Value(Value::Nothing { span: call.head })) - } - } - */ - Ok(iter.into_pipeline_data()) - - // Ok(PipelineData::Value(Value::Nothing { span: call.head })) } } From 9baf72015630750c296e5a0cb089f9a81da861c5 Mon Sep 17 00:00:00 2001 From: Michael Angerman Date: Wed, 27 Oct 2021 08:07:37 -0700 Subject: [PATCH 09/10] add in an example --- crates/nu-command/src/filters/last.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/crates/nu-command/src/filters/last.rs b/crates/nu-command/src/filters/last.rs index 77cad9604c..57223981f7 100644 --- a/crates/nu-command/src/filters/last.rs +++ b/crates/nu-command/src/filters/last.rs @@ -2,7 +2,9 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape}; +use nu_protocol::{ + Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, Value, +}; use std::convert::TryInto; #[derive(Clone)] @@ -25,6 +27,17 @@ impl Command for Last { "Show only the last number of rows." } + fn examples(&self) -> Vec { + vec![Example { + example: "[1,2,3] | last 2", + description: "Get the last 2 items", + result: Some(Value::List { + vals: vec![Value::test_int(2), Value::test_int(3)], + span: Span::unknown(), + }), + }] + } + fn run( &self, engine_state: &EngineState, @@ -58,3 +71,15 @@ fn rows_to_skip(count: i64, rows: Option) -> i64 { return 0; }; } + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_examples() { + use crate::test_examples; + + test_examples(Last {}) + } +} From c114f41545ac034ca38d803bd86042b60eb3487d Mon Sep 17 00:00:00 2001 From: Michael Angerman Date: Wed, 27 Oct 2021 08:35:42 -0700 Subject: [PATCH 10/10] clippy fix --- crates/nu-command/src/filters/last.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/nu-command/src/filters/last.rs b/crates/nu-command/src/filters/last.rs index 57223981f7..a878076801 100644 --- a/crates/nu-command/src/filters/last.rs +++ b/crates/nu-command/src/filters/last.rs @@ -66,10 +66,10 @@ fn rows_to_skip(count: i64, rows: Option) -> i64 { }; if end_rows_desired < count { - return count - end_rows_desired; + count - end_rows_desired } else { - return 0; - }; + 0 + } } #[cfg(test)]