mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
ListStream
touchup (#12524)
# Description Does some misc changes to `ListStream`: - Moves it into its own module/file separate from `RawStream`. - `ListStream`s now have an associated `Span`. - This required changes to `ListStreamInfo` in `nu-plugin`. Note sure if this is a breaking change for the plugin protocol. - Hides the internals of `ListStream` but also adds a few more methods. - This includes two functions to more easily alter a stream (these take a `ListStream` and return a `ListStream` instead of having to go through the whole `into_pipeline_data(..)` route). - `map`: takes a `FnMut(Value) -> Value` - `modify`: takes a function to modify the inner stream.
This commit is contained in:
@ -60,8 +60,8 @@ impl PluginCommand for Generate {
|
||||
call: &EvaluatedCall,
|
||||
_input: PipelineData,
|
||||
) -> Result<PipelineData, LabeledError> {
|
||||
let head = call.head;
|
||||
let engine = engine.clone();
|
||||
let call = call.clone();
|
||||
let initial: Value = call.req(0)?;
|
||||
let closure = call.req(1)?;
|
||||
|
||||
@ -83,9 +83,9 @@ impl PluginCommand for Generate {
|
||||
})
|
||||
.transpose()
|
||||
})
|
||||
.map(|result| result.unwrap_or_else(|err| Value::error(err, call.head)))
|
||||
.map(|result| result.unwrap_or_else(|err| Value::error(err, head)))
|
||||
})
|
||||
.into_pipeline_data(None))
|
||||
.into_pipeline_data(head, None))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,12 +50,11 @@ impl PluginCommand for Seq {
|
||||
call: &EvaluatedCall,
|
||||
_input: PipelineData,
|
||||
) -> Result<PipelineData, LabeledError> {
|
||||
let head = call.head;
|
||||
let first: i64 = call.req(0)?;
|
||||
let last: i64 = call.req(1)?;
|
||||
let span = call.head;
|
||||
let iter = (first..=last).map(move |number| Value::int(number, span));
|
||||
let list_stream = ListStream::from_stream(iter, None);
|
||||
Ok(PipelineData::ListStream(list_stream, None))
|
||||
let iter = (first..=last).map(move |number| Value::int(number, head));
|
||||
Ok(ListStream::new(iter, head, None).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user