mirror of
https://github.com/nushell/nushell.git
synced 2025-08-13 15:27:30 +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:
@ -72,7 +72,7 @@ impl Command for EachWhile {
|
||||
|
||||
let metadata = input.metadata();
|
||||
match input {
|
||||
PipelineData::Empty => Ok(PipelineData::Empty),
|
||||
PipelineData::Empty => Ok(PipelineData::empty()),
|
||||
PipelineData::Value(Value::Range { .. }, ..)
|
||||
| PipelineData::Value(Value::List { .. }, ..)
|
||||
| PipelineData::ListStream(..) => {
|
||||
@ -109,7 +109,7 @@ impl Command for EachWhile {
|
||||
.fuse()
|
||||
.into_pipeline_data(head, engine_state.signals().clone()))
|
||||
} else {
|
||||
Ok(PipelineData::Empty)
|
||||
Ok(PipelineData::empty())
|
||||
}
|
||||
}
|
||||
// This match allows non-iterables to be accepted,
|
||||
|
@ -55,7 +55,7 @@ fn from_url(input: PipelineData, head: Span) -> Result<PipelineData, ShellError>
|
||||
.map(|(k, v)| (k, Value::string(v, head)))
|
||||
.collect();
|
||||
|
||||
Ok(PipelineData::Value(Value::record(record, head), metadata))
|
||||
Ok(PipelineData::value(Value::record(record, head), metadata))
|
||||
}
|
||||
_ => Err(ShellError::UnsupportedInput {
|
||||
msg: "String not compatible with URL encoding".to_string(),
|
||||
|
@ -113,7 +113,7 @@ fn format_bits(
|
||||
let cell_paths = (!cell_paths.is_empty()).then_some(cell_paths);
|
||||
|
||||
if let PipelineData::ByteStream(stream, metadata) = input {
|
||||
Ok(PipelineData::ByteStream(
|
||||
Ok(PipelineData::byte_stream(
|
||||
byte_stream_to_bits(stream, head),
|
||||
metadata,
|
||||
))
|
||||
|
@ -191,7 +191,7 @@ fn format(
|
||||
// We can only handle a Record or a List of Records
|
||||
match data_as_value {
|
||||
Value::Record { .. } => match format_record(format_operations, &data_as_value, config) {
|
||||
Ok(value) => Ok(PipelineData::Value(Value::string(value, head_span), None)),
|
||||
Ok(value) => Ok(PipelineData::value(Value::string(value, head_span), None)),
|
||||
Err(value) => Err(value),
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user