mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 08:26:22 +02:00
Improve external output in subexprs (#294)
This commit is contained in:
@ -41,7 +41,7 @@ impl Command for SubCommand {
|
||||
|
||||
pub fn maximum(values: &[Value], head: &Span) -> Result<Value, ShellError> {
|
||||
let max_func = reducer_for(Reduce::Maximum);
|
||||
max_func(Value::nothing(), values.to_vec(), *head)
|
||||
max_func(Value::nothing(*head), values.to_vec(), *head)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -41,7 +41,7 @@ impl Command for SubCommand {
|
||||
|
||||
pub fn minimum(values: &[Value], head: &Span) -> Result<Value, ShellError> {
|
||||
let min_func = reducer_for(Reduce::Minimum);
|
||||
min_func(Value::nothing(), values.to_vec(), *head)
|
||||
min_func(Value::nothing(*head), values.to_vec(), *head)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -42,7 +42,7 @@ impl Command for SubCommand {
|
||||
/// Calculate product of given values
|
||||
pub fn product(values: &[Value], head: &Span) -> Result<Value, ShellError> {
|
||||
let product_func = reducer_for(Reduce::Product);
|
||||
product_func(Value::nothing(), values.to_vec(), *head)
|
||||
product_func(Value::nothing(*head), values.to_vec(), *head)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -24,7 +24,7 @@ pub fn reducer_for(command: Reduce) -> ReducerFunction {
|
||||
pub fn max(data: Vec<Value>, head: Span) -> Result<Value, ShellError> {
|
||||
let mut biggest = data
|
||||
.first()
|
||||
.ok_or_else(|| ShellError::UnsupportedInput("Empty input".to_string(), Span::unknown()))?
|
||||
.ok_or_else(|| ShellError::UnsupportedInput("Empty input".to_string(), head))?
|
||||
.clone();
|
||||
|
||||
for value in &data {
|
||||
@ -48,7 +48,7 @@ pub fn max(data: Vec<Value>, head: Span) -> Result<Value, ShellError> {
|
||||
pub fn min(data: Vec<Value>, head: Span) -> Result<Value, ShellError> {
|
||||
let mut smallest = data
|
||||
.first()
|
||||
.ok_or_else(|| ShellError::UnsupportedInput("Empty input".to_string(), Span::unknown()))?
|
||||
.ok_or_else(|| ShellError::UnsupportedInput("Empty input".to_string(), head))?
|
||||
.clone();
|
||||
|
||||
for value in &data {
|
||||
@ -87,9 +87,9 @@ pub fn sum(data: Vec<Value>, head: Span) -> Result<Value, ShellError> {
|
||||
}),
|
||||
None => Err(ShellError::UnsupportedInput(
|
||||
"Empty input".to_string(),
|
||||
Span::unknown(),
|
||||
head,
|
||||
)),
|
||||
_ => Ok(Value::nothing()),
|
||||
_ => Ok(Value::nothing(head)),
|
||||
}?;
|
||||
|
||||
for value in &data {
|
||||
@ -127,7 +127,7 @@ pub fn product(data: Vec<Value>, head: Span) -> Result<Value, ShellError> {
|
||||
"Empty input".to_string(),
|
||||
Span::unknown(),
|
||||
)),
|
||||
_ => Ok(Value::nothing()),
|
||||
_ => Ok(Value::nothing(head)),
|
||||
}?;
|
||||
|
||||
for value in &data {
|
||||
|
@ -48,7 +48,7 @@ impl Command for SubCommand {
|
||||
|
||||
pub fn summation(values: &[Value], head: &Span) -> Result<Value, ShellError> {
|
||||
let sum_func = reducer_for(Reduce::Summation);
|
||||
sum_func(Value::nothing(), values.to_vec(), *head)
|
||||
sum_func(Value::nothing(*head), values.to_vec(), *head)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
Reference in New Issue
Block a user