mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 20:27:44 +02:00
Refactor: introduce 2 associated functions to PipelineData
(#16233)
# Description As title: this pr is try to introduce 2 functions to `PipelineData`: 1. PipelineData::list_stream --> create a PipelineData::ListStream 2. PipelineData::byte_stream -> create a PipelineData::ByteStream And use these functions everywhere. ### Reason behind this change I tried to implement `pipefail` feature, but this would required to change `PipelineData` from enum to struct. So use these functions can reduce diff if I finally change to struct. [Discord message here](https://discord.com/channels/601130461678272522/615962413203718156/1396999539000479784) is my plan. # User-Facing Changes NaN # Tests + Formatting NaN # After Submitting NaN
This commit is contained in:
@ -48,7 +48,7 @@ impl PluginCommand for CollectBytes {
|
||||
call: &EvaluatedCall,
|
||||
input: PipelineData,
|
||||
) -> Result<PipelineData, LabeledError> {
|
||||
Ok(PipelineData::ByteStream(
|
||||
Ok(PipelineData::byte_stream(
|
||||
ByteStream::from_result_iter(
|
||||
input.into_iter().map(Value::coerce_into_binary),
|
||||
call.head,
|
||||
|
@ -45,6 +45,6 @@ impl PluginCommand for Ctrlc {
|
||||
eprintln!("interrupt status: {:?}", engine.signals().interrupted());
|
||||
eprintln!("peace.");
|
||||
|
||||
Ok(PipelineData::Empty)
|
||||
Ok(PipelineData::empty())
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ impl PluginCommand for ForEach {
|
||||
let result = engine.eval_closure(&closure, vec![value.clone()], Some(value))?;
|
||||
eprintln!("{}", result.to_expanded_string(", ", &config));
|
||||
}
|
||||
Ok(PipelineData::Empty)
|
||||
Ok(PipelineData::empty())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ impl PluginCommand for Sum {
|
||||
.with_label("can't be used here", call.head));
|
||||
}
|
||||
}
|
||||
Ok(PipelineData::Value(acc.to_value(call.head), None))
|
||||
Ok(PipelineData::value(acc.to_value(call.head), None))
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user