forked from extern/nushell
Fix up for_in
This commit is contained in:
@ -3,6 +3,7 @@ use std::{cell::RefCell, collections::HashMap, rc::Rc};
|
||||
|
||||
use crate::{ShellError, Value, VarId};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct EvaluationContext {
|
||||
pub engine_state: Rc<RefCell<EngineState>>,
|
||||
pub stack: Stack,
|
||||
|
@ -5,7 +5,7 @@ use crate::{span, BlockId, Span, Type};
|
||||
use crate::ShellError;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ValueStream(Rc<RefCell<dyn Iterator<Item = Value>>>);
|
||||
pub struct ValueStream(pub Rc<RefCell<dyn Iterator<Item = Value>>>);
|
||||
|
||||
impl ValueStream {
|
||||
pub fn into_string(self) -> String {
|
||||
@ -18,6 +18,10 @@ impl ValueStream {
|
||||
.join(", ".into())
|
||||
)
|
||||
}
|
||||
|
||||
pub fn from_stream(input: impl Iterator<Item = Value> + 'static) -> ValueStream {
|
||||
ValueStream(Rc::new(RefCell::new(input)))
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for ValueStream {
|
||||
@ -41,9 +45,12 @@ pub trait IntoValueStream {
|
||||
fn into_value_stream(self) -> ValueStream;
|
||||
}
|
||||
|
||||
impl IntoValueStream for Vec<Value> {
|
||||
impl<T> IntoValueStream for T
|
||||
where
|
||||
T: Iterator<Item = Value> + 'static,
|
||||
{
|
||||
fn into_value_stream(self) -> ValueStream {
|
||||
ValueStream(Rc::new(RefCell::new(self.into_iter())))
|
||||
ValueStream::from_stream(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user