Fix issue in external subexpression paths (#3642)

* Fix issue in external subexpression paths

* new clippy dropped

* clippy
This commit is contained in:
JT 2021-06-18 07:59:58 +12:00 committed by GitHub
parent 6c2c16a971
commit d9d956e54f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
159 changed files with 285 additions and 324 deletions

View file

@ -357,11 +357,11 @@ mod tests {
let ui = cli_app();
ui.parse("nu")?;
assert_eq!(ui.version(), false);
assert_eq!(ui.help(), false);
assert_eq!(ui.takes_stdin(), false);
assert_eq!(ui.save_history(), true);
assert_eq!(ui.skip_plugins(), false);
assert!(!ui.version());
assert!(!ui.help());
assert!(!ui.takes_stdin());
assert!(ui.save_history());
assert!(!ui.skip_plugins());
assert_eq!(ui.config(), None);
assert_eq!(ui.loglevel(), None);
assert_eq!(ui.debug(), None);
@ -460,7 +460,7 @@ mod tests {
let ui = cli_app();
ui.parse("nu --version")?;
assert_eq!(ui.version(), true);
assert!(ui.version());
Ok(())
}
@ -469,7 +469,7 @@ mod tests {
let ui = cli_app();
ui.parse("nu --help")?;
assert_eq!(ui.help(), true);
assert!(ui.help());
Ok(())
}
@ -478,7 +478,7 @@ mod tests {
let ui = cli_app();
ui.parse("nu --stdin")?;
assert_eq!(ui.takes_stdin(), true);
assert!(ui.takes_stdin());
Ok(())
}
@ -487,7 +487,7 @@ mod tests {
let ui = cli_app();
ui.parse("nu --no-history")?;
assert_eq!(ui.save_history(), false);
assert!(!ui.save_history());
Ok(())
}
@ -496,7 +496,7 @@ mod tests {
let ui = cli_app();
ui.parse("nu --skip-plugins")?;
assert_eq!(ui.skip_plugins(), true);
assert!(ui.skip_plugins());
Ok(())
}

View file

@ -155,14 +155,14 @@ fn convert_cmd(cmd: Cmd) -> rustyline::Cmd {
fn convert_keybinding(keybinding: Keybinding) -> (rustyline::KeyEvent, rustyline::Cmd) {
let rusty_modifiers = match keybinding.modifiers {
Some(mods) => match mods {
NuModifiers::CTRL => Some(Modifiers::CTRL),
NuModifiers::ALT => Some(Modifiers::ALT),
NuModifiers::SHIFT => Some(Modifiers::SHIFT),
NuModifiers::NONE => Some(Modifiers::NONE),
NuModifiers::CTRL_SHIFT => Some(Modifiers::CTRL_SHIFT),
NuModifiers::ALT_SHIFT => Some(Modifiers::ALT_SHIFT),
NuModifiers::CTRL_ALT => Some(Modifiers::CTRL_ALT),
NuModifiers::CTRL_ALT_SHIFT => Some(Modifiers::CTRL_ALT_SHIFT),
NuModifiers::Ctrl => Some(Modifiers::CTRL),
NuModifiers::Alt => Some(Modifiers::ALT),
NuModifiers::Shift => Some(Modifiers::SHIFT),
NuModifiers::None => Some(Modifiers::NONE),
NuModifiers::CtrlShift => Some(Modifiers::CTRL_SHIFT),
NuModifiers::AltShift => Some(Modifiers::ALT_SHIFT),
NuModifiers::CtrlAlt => Some(Modifiers::CTRL_ALT),
NuModifiers::CtrlAltShift => Some(Modifiers::CTRL_ALT_SHIFT),
// _ => None,
},
None => None,
@ -412,24 +412,31 @@ pub enum CharSearch {
/// The set of modifier keys that were triggered along with a key press.
#[derive(Serialize, Deserialize)]
#[allow(non_camel_case_types)]
#[allow(clippy::clippy::upper_case_acronyms)]
pub enum NuModifiers {
/// Control modifier
CTRL = 8,
#[serde(alias = "CTRL")]
Ctrl = 8,
/// Escape or Alt modifier
ALT = 4,
#[serde(alias = "ALT")]
Alt = 4,
/// Shift modifier
SHIFT = 2,
#[serde(alias = "SHIFT")]
Shift = 2,
/// No modifier
NONE = 0,
#[serde(alias = "NONE")]
None = 0,
/// Ctrl + Shift
CTRL_SHIFT = 10,
#[serde(alias = "CTRL_SHIFT")]
CtrlShift = 10,
/// Alt + Shift
ALT_SHIFT = 6,
#[serde(alias = "ALT_SHIFT")]
AltShift = 6,
/// Ctrl + Alt
CTRL_ALT = 12,
#[serde(alias = "CTRL_ALT")]
CtrlAlt = 12,
/// Ctrl + Alt + Shift
CTRL_ALT_SHIFT = 14,
#[serde(alias = "CTRL_ALT_SHIFT")]
CtrlAltShift = 14,
}
/// The number of times one command should be repeated.

View file

@ -36,24 +36,7 @@ pub(crate) use nu_engine::Host;
pub(crate) use nu_errors::ShellError;
#[allow(unused_imports)]
pub(crate) use nu_protocol::outln;
pub(crate) use nu_stream::ActionStream;
#[allow(unused_imports)]
pub(crate) use nu_value_ext::ValueExt;
#[allow(unused_imports)]
pub(crate) use std::sync::atomic::Ordering;
#[allow(clippy::clippy::wrong_self_convention)]
pub trait FromInputStream {
fn from_input_stream(self) -> ActionStream;
}
impl<T> FromInputStream for T
where
T: Iterator<Item = nu_protocol::Value> + Send + Sync + 'static,
{
fn from_input_stream(self) -> ActionStream {
ActionStream {
values: Box::new(self.map(nu_protocol::ReturnSuccess::value)),
}
}
}

View file

@ -118,7 +118,7 @@ fn all(args: CommandArgs) -> Result<OutputStream, ShellError> {
});
scope.exit_scope();
Ok(result?.to_output_stream())
Ok(result?.into_output_stream())
}
#[cfg(test)]

View file

@ -121,7 +121,7 @@ fn any(args: CommandArgs) -> Result<OutputStream, ShellError> {
});
scope.exit_scope();
Ok(result?.to_output_stream())
Ok(result?.into_output_stream())
}
#[cfg(test)]

View file

@ -46,7 +46,7 @@ impl WholeStreamCommand for Command {
Ok(prepend
.into_iter()
.chain(args.input.into_iter().chain(vec![value]))
.to_output_stream())
.into_output_stream())
}
fn examples(&self) -> Vec<Example> {

View file

@ -98,7 +98,7 @@ pub fn cal(args: CommandArgs) -> Result<ActionStream, ShellError> {
current_day_option,
)?;
Ok(calendar_vec_deque.into_iter().to_action_stream())
Ok(calendar_vec_deque.into_iter().into_action_stream())
}
fn get_invalid_year_shell_error(year_tag: &Tag) -> ShellError {

View file

@ -187,7 +187,7 @@ impl WholeStreamCommand for Char {
dict.insert_untagged("unicode", UntaggedValue::string(unicode_parts.join(" ")));
dict.into_value()
})
.to_output_stream())
.into_output_stream())
} else if let Some(name) = args.name {
if args.unicode {
if !args.rest.is_empty() {

View file

@ -460,7 +460,7 @@ fn spawn(
});
let stream = ChannelReceiver::new(rx);
Ok(stream.to_input_stream())
Ok(stream.into_input_stream())
}
Err(e) => Err(ShellError::labeled_error(
format!("{}", e),

View file

@ -61,7 +61,7 @@ pub fn compact(args: CommandArgs) -> Result<OutputStream, ShellError> {
false
}
})
.to_output_stream())
.into_output_stream())
}
#[cfg(test)]

View file

@ -44,5 +44,5 @@ fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
series.as_mut().rename(name.item.as_ref());
Ok(OutputStream::one(series.to_value(tag)))
Ok(OutputStream::one(series.into_value(tag)))
}

View file

@ -114,5 +114,5 @@ fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
tag: Tag::unknown(),
};
Ok(InputStream::one(tagged_value).to_output_stream())
Ok(InputStream::one(tagged_value).into_output_stream())
}

View file

@ -23,7 +23,7 @@ impl WholeStreamCommand for DataFrame {
let df = NuDataFrame::try_from_iter(args.input, &tag)?;
Ok(InputStream::one(df.to_value(tag)))
Ok(InputStream::one(df.into_value(tag)))
}
fn examples(&self) -> Vec<Example> {

View file

@ -70,5 +70,5 @@ fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
tag: Tag::unknown(),
};
Ok(InputStream::one(tagged_value).to_output_stream())
Ok(InputStream::one(tagged_value).into_output_stream())
}

View file

@ -31,7 +31,7 @@ impl WholeStreamCommand for DataFrame {
let series = NuSeries::try_from_iter(args.input, name)?;
Ok(InputStream::one(series.to_value(tag)))
Ok(InputStream::one(series.into_value(tag)))
}
fn examples(&self) -> Vec<Example> {

View file

@ -62,5 +62,5 @@ fn command(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
.with_column(series)
.map_err(|e| parse_polars_error::<&str>(&e, &tag.span, None))?;
Ok(OutputStream::one(df.to_value(tag)))
Ok(OutputStream::one(df.into_value(tag)))
}

View file

@ -91,7 +91,7 @@ pub fn format(args: CommandArgs) -> Result<OutputStream, ShellError> {
&tag,
)),
})
.to_input_stream())
.into_input_stream())
}
#[cfg(test)]

View file

@ -54,7 +54,7 @@ fn list_timezone(args: CommandArgs) -> Result<OutputStream, ShellError> {
Ok(UntaggedValue::Row(Dictionary { entries }).into_value(&tag))
});
Ok(list.into_iter().to_input_stream())
Ok(list.into_iter().into_input_stream())
}
#[cfg(test)]

View file

@ -90,7 +90,7 @@ fn to_table(args: CommandArgs) -> Result<OutputStream, ShellError> {
&tag,
)),
})
.to_input_stream())
.into_input_stream())
}
#[cfg(test)]

View file

@ -82,7 +82,7 @@ fn to_timezone(args: CommandArgs) -> Result<OutputStream, ShellError> {
&tag,
)),
})
.to_input_stream())
.into_input_stream())
}
fn error_message(err: ParseErrorKind) -> &'static str {

View file

@ -37,7 +37,7 @@ fn debug_value(args: CommandArgs) -> Result<ActionStream, ShellError> {
ReturnSuccess::debug_value(v)
}
})
.to_action_stream())
.into_action_stream())
}
#[cfg(test)]

View file

@ -64,7 +64,7 @@ fn default(args: CommandArgs) -> Result<ActionStream, ShellError> {
ReturnSuccess::value(item)
}
})
.to_action_stream())
.into_action_stream())
}
#[cfg(test)]

View file

@ -36,7 +36,7 @@ pub fn describe(args: CommandArgs) -> Result<ActionStream, ShellError> {
UntaggedValue::string(name).into_value(Tag::unknown_anchor(row.tag.span)),
)
})
.to_action_stream())
.into_action_stream())
}
#[cfg(test)]

View file

@ -118,12 +118,12 @@ fn do_(args: CommandArgs) -> Result<OutputStream, ShellError> {
Ok(mut stream) => {
let output = stream.drain_vec();
context.clear_errors();
Ok(output.into_iter().to_output_stream())
Ok(output.into_iter().into_output_stream())
}
Err(_) => Ok(OutputStream::empty()),
}
} else {
result.map(|x| x.to_output_stream())
result.map(|x| x.into_output_stream())
}
}

View file

@ -64,7 +64,7 @@ fn drop(args: CommandArgs) -> Result<OutputStream, ShellError> {
Ok(select_fields(&item, descs, item.tag()))
})
.to_input_stream())
.into_input_stream())
}
#[cfg(test)]

View file

@ -57,7 +57,7 @@ fn drop(args: CommandArgs) -> Result<OutputStream, ShellError> {
};
Ok(if rows_to_drop == 0 {
v.into_iter().map(Ok).to_input_stream()
v.into_iter().map(Ok).into_input_stream()
} else {
let k = if v.len() < rows_to_drop {
0
@ -67,6 +67,6 @@ fn drop(args: CommandArgs) -> Result<OutputStream, ShellError> {
let iter = v.into_iter().map(Ok).take(k);
iter.to_input_stream()
iter.into_input_stream()
})
}

View file

@ -158,7 +158,7 @@ fn du(args: CommandArgs) -> Result<ActionStream, ShellError> {
Err(e) => vec![Err(e)],
})
.interruptible(ctrl_c_copy)
.to_action_stream())
.into_action_stream())
}
fn glob_err_into(e: GlobError) -> ShellError {

View file

@ -82,7 +82,7 @@ pub fn process_row(
let input_stream = if !captured_block.block.params.positional.is_empty() {
InputStream::empty()
} else {
vec![Ok(input_clone)].into_iter().to_input_stream()
vec![Ok(input_clone)].into_iter().into_input_stream()
};
context.scope.enter_scope();
@ -138,7 +138,7 @@ fn each(args: CommandArgs) -> Result<OutputStream, ShellError> {
}
})
.flatten()
.to_output_stream())
.into_output_stream())
} else {
Ok(args
.input
@ -152,7 +152,7 @@ fn each(args: CommandArgs) -> Result<OutputStream, ShellError> {
}
})
.flatten()
.to_output_stream())
.into_output_stream())
}
}

View file

@ -53,7 +53,7 @@ impl WholeStreamCommand for EachGroup {
external_redirection,
};
Ok(each_group_iterator.flatten().map(Ok).to_input_stream())
Ok(each_group_iterator.flatten().map(Ok).into_input_stream())
}
}

View file

@ -88,7 +88,7 @@ impl WholeStreamCommand for EachWindow {
.flatten()
.flatten()
.map(Ok)
.to_input_stream())
.into_input_stream())
}
}

View file

@ -102,7 +102,7 @@ fn is_empty(args: CommandArgs) -> Result<ActionStream, ShellError> {
}
})
.flatten()
.to_action_stream());
.into_action_stream());
}
Ok(input
@ -115,7 +115,7 @@ fn is_empty(args: CommandArgs) -> Result<ActionStream, ShellError> {
}
})
.flatten()
.to_action_stream())
.into_action_stream())
}
fn process_row(
@ -129,7 +129,7 @@ fn process_row(
if let Some(default_block) = &*default_block {
let for_block = input.clone();
let input_stream = vec![Ok(for_block)].into_iter().to_input_stream();
let input_stream = vec![Ok(for_block)].into_iter().into_input_stream();
context.scope.enter_scope();
context.scope.add_vars(&default_block.captured.entries);

View file

@ -130,7 +130,7 @@ fn enter(args: CommandArgs) -> Result<ActionStream, ShellError> {
},
)))
})
.to_action_stream())
.into_action_stream())
} else {
Ok(ActionStream::one(ReturnSuccess::action(
CommandAction::EnterValueShell(tagged_contents),

View file

@ -72,7 +72,7 @@ fn every(args: CommandArgs) -> Result<ActionStream, ShellError> {
None
}
})
.to_action_stream())
.into_action_stream())
}
#[cfg(test)]

View file

@ -56,7 +56,7 @@ fn first(args: CommandArgs) -> Result<ActionStream, ShellError> {
1
};
Ok(input.take(rows_desired).to_action_stream())
Ok(input.take(rows_desired).into_action_stream())
}
#[cfg(test)]

View file

@ -54,7 +54,7 @@ fn flatten(args: CommandArgs) -> Result<ActionStream, ShellError> {
Ok(input
.map(move |item| flat_value(&columns, &item, &tag).into_iter())
.flatten()
.to_action_stream())
.into_action_stream())
}
enum TableInside<'a> {

View file

@ -80,7 +80,7 @@ pub fn process_row(
let input_stream = if !captured_block.block.params.positional.is_empty() {
InputStream::empty()
} else {
vec![Ok(input_clone)].into_iter().to_input_stream()
vec![Ok(input_clone)].into_iter().into_input_stream()
};
context.scope.enter_scope();
@ -139,7 +139,7 @@ fn for_in(args: CommandArgs) -> Result<OutputStream, ShellError> {
}
})
.flatten()
.to_output_stream())
.into_output_stream())
} else {
Ok(input
.map(move |input| {
@ -151,7 +151,7 @@ fn for_in(args: CommandArgs) -> Result<OutputStream, ShellError> {
}
})
.flatten()
.to_output_stream())
.into_output_stream())
}
}

View file

@ -80,7 +80,7 @@ fn format_command(args: CommandArgs) -> Result<OutputStream, ShellError> {
Ok(UntaggedValue::string(output).into_untagged_value())
})
.to_input_stream())
.into_input_stream())
}
#[derive(Debug)]

View file

@ -101,7 +101,7 @@ fn filesize(args: CommandArgs) -> Result<OutputStream, ShellError> {
})
.flatten()
.map(Ok)
.to_input_stream())
.into_input_stream())
}
#[cfg(test)]

View file

@ -61,7 +61,7 @@ pub fn from_delimited_data(
Value {
value: UntaggedValue::Table(list),
..
} => Ok(list.into_iter().to_output_stream()),
} => Ok(list.into_iter().into_output_stream()),
x => Ok(OutputStream::one(x)),
},
Err(err) => {

View file

@ -51,7 +51,7 @@ fn from_ics(args: CommandArgs) -> Result<OutputStream, ShellError> {
}
}
Ok(output.into_iter().to_output_stream())
Ok(output.into_iter().into_output_stream())
}
fn calendar_to_value(calendar: IcalCalendar, tag: Tag) -> Value {

View file

@ -69,7 +69,7 @@ fn from_ini(args: CommandArgs) -> Result<OutputStream, ShellError> {
Value {
value: UntaggedValue::Table(list),
..
} => Ok(list.into_iter().to_output_stream()),
} => Ok(list.into_iter().into_output_stream()),
x => Ok(OutputStream::one(x)),
},
Err(_) => Err(ShellError::labeled_error_with_secondary(

View file

@ -96,14 +96,14 @@ fn from_json(args: CommandArgs) -> Result<OutputStream, ShellError> {
}
}
})
.to_output_stream())
.into_output_stream())
} else {
match from_json_string_to_value(concat_string.item, name_tag.clone()) {
Ok(x) => match x {
Value {
value: UntaggedValue::Table(list),
..
} => Ok(list.into_iter().to_output_stream()),
} => Ok(list.into_iter().into_output_stream()),
x => Ok(OutputStream::one(x)),
},

View file

@ -259,7 +259,7 @@ fn from_ssv(args: CommandArgs) -> Result<OutputStream, ShellError> {
Value {
value: UntaggedValue::Table(list),
..
} => list.into_iter().to_output_stream(),
} => list.into_iter().into_output_stream(),
x => OutputStream::one(x),
},
)

View file

@ -71,7 +71,7 @@ pub fn from_toml(args: CommandArgs) -> Result<OutputStream, ShellError> {
Value {
value: UntaggedValue::Table(list),
..
} => list.into_iter().to_output_stream(),
} => list.into_iter().into_output_stream(),
x => OutputStream::one(x),
},
Err(_) => {

View file

@ -45,7 +45,7 @@ fn from_vcf(args: CommandArgs) -> Result<OutputStream, ShellError> {
let collected: Vec<_> = iter.collect();
Ok(collected.into_iter().to_output_stream())
Ok(collected.into_iter().into_output_stream())
}
fn contact_to_value(contact: VcardContact, tag: Tag) -> Value {

View file

@ -106,7 +106,7 @@ fn from_xml(args: CommandArgs) -> Result<OutputStream, ShellError> {
Value {
value: UntaggedValue::Table(list),
..
} => list.into_iter().to_output_stream(),
} => list.into_iter().into_output_stream(),
x => OutputStream::one(x),
},
Err(_) => {

View file

@ -142,7 +142,7 @@ fn from_yaml(args: CommandArgs) -> Result<OutputStream, ShellError> {
Value {
value: UntaggedValue::Table(list),
..
} => Ok(list.into_iter().to_output_stream()),
} => Ok(list.into_iter().into_output_stream()),
x => Ok(OutputStream::one(x)),
},
Err(_) => Err(ShellError::labeled_error_with_secondary(

View file

@ -60,7 +60,7 @@ pub fn get(args: CommandArgs) -> Result<ActionStream, ShellError> {
Ok(descs
.into_iter()
.map(ReturnSuccess::value)
.to_action_stream())
.into_action_stream())
} else {
trace!("get {:?}", column_paths);
let output_stream = input
@ -72,7 +72,7 @@ pub fn get(args: CommandArgs) -> Result<ActionStream, ShellError> {
.collect::<Vec<_>>()
})
.flatten()
.to_action_stream();
.into_action_stream();
Ok(output_stream)
}
}

View file

@ -138,7 +138,7 @@ fn operate(args: CommandArgs) -> Result<OutputStream, ShellError> {
Ok(ret)
}
})
.to_input_stream())
.into_input_stream())
}
fn action(

View file

@ -70,7 +70,7 @@ fn operate(args: CommandArgs) -> Result<OutputStream, ShellError> {
Ok(ret)
}
})
.to_input_stream())
.into_input_stream())
}
fn action(input: &Value, tag: impl Into<Tag>) -> Result<Value, ShellError> {

View file

@ -102,7 +102,7 @@ pub fn headers(args: CommandArgs) -> Result<ActionStream, ShellError> {
)),
}
})
.to_action_stream())
.into_action_stream())
}
#[cfg(test)]

View file

@ -150,7 +150,7 @@ fn help(args: CommandArgs) -> Result<ActionStream, ShellError> {
ReturnSuccess::value(short_desc.into_value())
});
Ok(iterator.to_action_stream())
Ok(iterator.into_action_stream())
} else if rest[0].item == "generate_docs" {
Ok(ActionStream::one(ReturnSuccess::value(generate_docs(
&scope,

View file

@ -164,7 +164,7 @@ pub fn histogram(args: CommandArgs) -> Result<ActionStream, ShellError> {
ReturnSuccess::value(fact.into_value())
})
.to_action_stream())
.into_action_stream())
}
fn evaluator(by: ColumnPath) -> Box<dyn Fn(usize, &Value) -> Result<Value, ShellError> + Send> {

View file

@ -50,7 +50,7 @@ fn history(args: CommandArgs) -> Result<ActionStream, ShellError> {
Err(_) => None,
});
Ok(output.to_action_stream())
Ok(output.into_action_stream())
} else {
Err(ShellError::labeled_error(
"Could not open history",

View file

@ -70,7 +70,7 @@ fn process_row(
tag: block_tag,
} => {
let for_block = input.clone();
let input_stream = vec![Ok(for_block)].into_iter().to_input_stream();
let input_stream = vec![Ok(for_block)].into_iter().into_input_stream();
context.scope.enter_scope();
context.scope.add_vars(&block.captured.entries);
@ -173,5 +173,5 @@ fn insert(args: CommandArgs) -> Result<ActionStream, ShellError> {
}
})
.flatten()
.to_action_stream())
.into_action_stream())
}

View file

@ -136,7 +136,7 @@ fn into_binary(args: CommandArgs) -> Result<OutputStream, ShellError> {
Ok(ret)
}
})
.to_input_stream())
.into_input_stream())
}
fn int_to_endian(n: i64) -> Vec<u8> {

View file

@ -98,7 +98,7 @@ fn into_int(args: CommandArgs) -> Result<OutputStream, ShellError> {
Ok(ret)
}
})
.to_input_stream())
.into_input_stream())
}
pub fn action(input: &Value, tag: impl Into<Tag>) -> Result<Value, ShellError> {

View file

@ -104,7 +104,7 @@ fn into_string(args: CommandArgs) -> Result<OutputStream, ShellError> {
Ok(ret)
}
})
.to_input_stream())
.into_input_stream())
}
pub fn action(

View file

@ -57,7 +57,7 @@ fn keep(args: CommandArgs) -> Result<OutputStream, ShellError> {
1
};
Ok(args.input.take(rows_desired).to_output_stream())
Ok(args.input.take(rows_desired).into_output_stream())
}
#[cfg(test)]

View file

@ -79,7 +79,7 @@ impl WholeStreamCommand for SubCommand {
!matches!(result, Ok(ref v) if v.is_true())
})
.to_output_stream())
.into_output_stream())
}
}

View file

@ -82,7 +82,7 @@ impl WholeStreamCommand for SubCommand {
matches!(result, Ok(ref v) if v.is_true())
})
.to_output_stream())
.into_output_stream())
}
}

View file

@ -34,7 +34,7 @@ impl WholeStreamCommand for Length {
done: false,
tag,
}
.to_output_stream())
.into_output_stream())
}
fn examples(&self) -> Vec<Example> {

View file

@ -112,7 +112,7 @@ fn lines(args: CommandArgs) -> Result<ActionStream, ShellError> {
}
})
.flatten()
.to_action_stream())
.into_action_stream())
}
#[cfg(test)]

View file

@ -32,7 +32,7 @@ impl WholeStreamCommand for SubCommand {
}
other => abs_default(other),
});
Ok(mapped.to_output_stream())
Ok(mapped.into_output_stream())
}
fn examples(&self) -> Vec<Example> {

View file

@ -68,7 +68,7 @@ fn operate(args: CommandArgs) -> Result<OutputStream, ShellError> {
UntaggedValue::Primitive(Primitive::Int(val)) => UntaggedValue::int(val).into(),
other => round_default(other),
});
Ok(mapped.to_output_stream())
Ok(mapped.into_output_stream())
}
fn round_big_int(val: BigInt) -> Value {

View file

@ -40,7 +40,7 @@ fn operate(args: CommandArgs) -> OutputStream {
UntaggedValue::Primitive(Primitive::Decimal(val)) => sqrt_big_decimal(val),
other => sqrt_default(other),
});
mapped.to_output_stream()
mapped.into_output_stream()
}
fn sqrt_big_decimal(val: BigDecimal) -> Value {

View file

@ -55,7 +55,7 @@ pub fn run_with_numerical_functions_on_stream(
UntaggedValue::Primitive(Primitive::Decimal(val)) => decimal_function(val),
other => default_function(other),
});
Ok(mapped.to_output_stream())
Ok(mapped.into_output_stream())
}
pub fn calculate(values: &[Value], name: &Tag, mf: MathFunction) -> Result<Value, ShellError> {

View file

@ -92,7 +92,7 @@ fn merge(args: CommandArgs) -> Result<ActionStream, ShellError> {
None => ReturnSuccess::value(value),
}
})
.to_action_stream())
.into_action_stream())
}
#[cfg(test)]

View file

@ -159,7 +159,7 @@ fn operate(args: CommandArgs) -> Result<OutputStream, ShellError> {
))
}
})
.to_input_stream())
.into_input_stream())
} else if let Some(before) = before {
let member = columns.remove(0);
@ -208,7 +208,7 @@ fn operate(args: CommandArgs) -> Result<OutputStream, ShellError> {
))
}
})
.to_input_stream())
.into_input_stream())
} else {
Err(ShellError::labeled_error(
"no columns given",

View file

@ -67,7 +67,7 @@ fn nth(args: CommandArgs) -> Result<OutputStream, ShellError> {
skip,
current: 0,
}
.to_output_stream())
.into_output_stream())
}
struct NthIterator {

View file

@ -96,7 +96,7 @@ pub fn operate(args: CommandArgs) -> Result<OutputStream, ShellError> {
}
}
Ok(parsed.into_iter().to_output_stream())
Ok(parsed.into_iter().into_output_stream())
}
fn build_regex(input: &str, tag: Tag) -> Result<String, ShellError> {

View file

@ -141,7 +141,7 @@ where
Err(e) => Value::error(e),
},
)
.to_output_stream()
.into_output_stream()
} else {
// join the whole input stream
match join_path(&parts.collect_vec(), &span) {

View file

@ -190,7 +190,7 @@ where
ret
})
.to_output_stream()
.into_output_stream()
}
fn operate<F, T>(
@ -211,7 +211,7 @@ where
Err(e) => Value::error(e),
},
)
.to_output_stream()
.into_output_stream()
} else {
operate_column_paths(input, action, span, args)
}

View file

@ -104,7 +104,7 @@ where
Ok(Value {
value: UntaggedValue::Table(parts),
..
}) => parts.into_iter().to_output_stream(),
}) => parts.into_iter().into_output_stream(),
Err(e) => OutputStream::one(Value::error(e)),
_ => OutputStream::one(Value::error(ShellError::labeled_error(
"Internal Error",
@ -113,7 +113,7 @@ where
))),
}
})
.to_output_stream()
.into_output_stream()
} else {
operate_column_paths(input, action, span, args)
}

View file

@ -146,7 +146,7 @@ pub fn pivot(args: CommandArgs) -> Result<ActionStream, ShellError> {
ReturnSuccess::value(dict.into_value())
}))
.to_action_stream())
.into_action_stream())
}
#[cfg(test)]

View file

@ -46,7 +46,7 @@ fn prepend(args: CommandArgs) -> Result<OutputStream, ShellError> {
let bos = vec![row].into_iter();
Ok(bos.chain(input).to_output_stream())
Ok(bos.chain(input).into_output_stream())
}
#[cfg(test)]

View file

@ -82,7 +82,7 @@ pub fn dice(args: CommandArgs) -> Result<OutputStream, ShellError> {
UntaggedValue::int(thread_rng.gen_range(1, sides + 1)).into_value(tag.clone())
});
Ok((iter).to_output_stream())
Ok((iter).into_output_stream())
}
#[cfg(test)]

View file

@ -91,7 +91,11 @@ fn range(args: CommandArgs) -> Result<OutputStream, ShellError> {
if from > to {
Ok(OutputStream::one(Value::nothing()))
} else {
Ok(args.input.skip(from).take(to - from + 1).to_output_stream())
Ok(args
.input
.skip(from)
.take(to - from + 1)
.into_output_stream())
}
}
}

View file

@ -84,7 +84,7 @@ fn process_row(
row: Value,
) -> Result<InputStream, ShellError> {
let row_clone = row.clone();
let input_stream = vec![Ok(row_clone)].into_iter().to_input_stream();
let input_stream = vec![Ok(row_clone)].into_iter().into_input_stream();
context.scope.enter_scope();
context.scope.add_vars(&block.captured.entries);
@ -178,7 +178,7 @@ fn reduce(args: CommandArgs) -> Result<ActionStream, ShellError> {
}))
})
})?
.to_action_stream())
.into_action_stream())
} else {
let initial = Ok(InputStream::one(start));
Ok(input
@ -205,7 +205,7 @@ fn reduce(args: CommandArgs) -> Result<ActionStream, ShellError> {
context.scope.exit_scope();
result
})?
.to_action_stream())
.into_action_stream())
}
}

View file

@ -50,7 +50,7 @@ fn reject(args: CommandArgs) -> Result<ActionStream, ShellError> {
Ok(args
.input
.map(move |item| ReturnSuccess::value(reject_fields(&item, &fields, &item.tag)))
.to_action_stream())
.into_action_stream())
}
#[cfg(test)]

View file

@ -99,7 +99,7 @@ pub fn rename(args: CommandArgs) -> Result<ActionStream, ShellError> {
)
}
})
.to_action_stream())
.into_action_stream())
}
#[cfg(test)]

View file

@ -40,7 +40,7 @@ impl WholeStreamCommand for Reverse {
#[allow(clippy::needless_collect)]
fn reverse(args: CommandArgs) -> Result<ActionStream, ShellError> {
let input = args.input.collect::<Vec<_>>();
Ok((input.into_iter().rev().map(ReturnSuccess::value)).to_action_stream())
Ok((input.into_iter().rev().map(ReturnSuccess::value)).into_action_stream())
}
#[cfg(test)]

View file

@ -67,7 +67,7 @@ pub fn roll(args: CommandArgs) -> Result<OutputStream, ShellError> {
.into_iter()
})
.flatten()
.to_output_stream())
.into_output_stream())
}
fn roll_by(value: Value, options: &Arguments) -> Option<Vec<Value>> {

View file

@ -40,7 +40,7 @@ pub fn roll(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
Ok(roll_down(values, &options)
.unwrap_or_else(|| vec![UntaggedValue::nothing().into_value(&name)])
.into_iter()
.to_output_stream())
.into_output_stream())
}
fn roll_down(values: Vec<Value>, Arguments { by: ref n }: &Arguments) -> Option<Vec<Value>> {

View file

@ -41,7 +41,7 @@ pub fn roll(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
Ok(roll_up(values, &options)
.unwrap_or_else(|| vec![UntaggedValue::nothing().into_value(&name)])
.into_iter()
.to_output_stream())
.into_output_stream())
}
fn roll_up(values: Vec<Value>, Arguments { by: ref n }: &Arguments) -> Option<Vec<Value>> {

View file

@ -108,5 +108,5 @@ pub fn rotate(args: CommandArgs) -> Result<ActionStream, ShellError> {
.rev()
.collect::<Vec<_>>())
.into_iter()
.to_action_stream())
.into_action_stream())
}

View file

@ -104,5 +104,5 @@ pub fn rotate(args: CommandArgs) -> Result<ActionStream, ShellError> {
})
.collect::<Vec<_>>())
.into_iter()
.to_action_stream())
.into_action_stream())
}

View file

@ -105,7 +105,7 @@ impl WholeStreamCommand for RunExternalCommand {
.shell_manager()
.cd(cd_args, args.call_info.name_tag);
return Ok(result?.to_action_stream());
return Ok(result?.into_action_stream());
}
}
@ -123,7 +123,7 @@ impl WholeStreamCommand for RunExternalCommand {
let _ = nu_ansi_term::enable_ansi_support();
}
Ok(result?.to_action_stream())
Ok(result?.into_action_stream())
}
}

View file

@ -152,5 +152,5 @@ fn select(args: CommandArgs) -> Result<OutputStream, ShellError> {
out.into_value()
}))
.to_output_stream())
.into_output_stream())
}

View file

@ -345,13 +345,13 @@ fn print_seq(
}
})
.collect();
(rows.into_iter()).to_output_stream()
(rows.into_iter()).into_output_stream()
} else {
let rows: Vec<Value> = ret_str
.lines()
.map(|v| v.to_str_value_create_tag())
.collect();
(rows.into_iter()).to_output_stream()
(rows.into_iter()).into_output_stream()
}
}

View file

@ -336,7 +336,7 @@ pub fn run_seq_dates(
.lines()
.map(|v| v.to_str_value_create_tag())
.collect();
Ok((rows.into_iter().map(ReturnSuccess::value)).to_action_stream())
Ok((rows.into_iter().map(ReturnSuccess::value)).into_action_stream())
}
#[cfg(test)]

View file

@ -31,7 +31,7 @@ fn shuffle(args: CommandArgs) -> ActionStream {
values
.into_iter()
.map(ReturnSuccess::value)
.to_action_stream()
.into_action_stream()
}
#[cfg(test)]

View file

@ -73,7 +73,7 @@ fn size(args: CommandArgs) -> ActionStream {
))
}
})
.to_action_stream()
.into_action_stream()
}
fn count(contents: &str, tag: impl Into<Tag>) -> Value {

View file

@ -45,7 +45,7 @@ fn skip(args: CommandArgs) -> Result<ActionStream, ShellError> {
1
};
Ok(input.skip(rows_desired).to_action_stream())
Ok(input.skip(rows_desired).into_action_stream())
}
#[cfg(test)]

View file

@ -82,7 +82,7 @@ impl WholeStreamCommand for SubCommand {
!matches!(result, Ok(ref v) if v.is_true())
})
.to_action_stream())
.into_action_stream())
}
}

View file

@ -83,7 +83,7 @@ impl WholeStreamCommand for SubCommand {
matches!(result, Ok(ref v) if v.is_true())
})
.to_action_stream())
.into_action_stream())
}
}

View file

@ -48,7 +48,7 @@ impl WholeStreamCommand for Sleep {
// `echo | sleep 1sec` - nothing
// `sleep 1sec` - table with 0 elements
Ok(SleepIterator::new(total_dur, ctrl_c).to_output_stream())
Ok(SleepIterator::new(total_dur, ctrl_c).into_output_stream())
// if input.is_empty() {
// Ok(OutputStream::empty())

View file

@ -118,7 +118,7 @@ fn sort_by(mut args: CommandArgs) -> Result<OutputStream, ShellError> {
vec.reverse()
}
Ok((vec.into_iter()).to_output_stream())
Ok((vec.into_iter()).into_output_stream())
}
pub fn sort(

View file

@ -47,7 +47,7 @@ fn split_chars(args: CommandArgs) -> ActionStream {
.collect::<Vec<_>>()
.into_iter()
.map(move |x| ReturnSuccess::value(Value::from(x.to_string())))
.to_action_stream()
.into_action_stream()
} else {
ActionStream::one(Err(ShellError::labeled_error_with_secondary(
"Expected a string from pipeline",
@ -58,7 +58,7 @@ fn split_chars(args: CommandArgs) -> ActionStream {
)))
}
})
.to_action_stream()
.into_action_stream()
}
#[cfg(test)]

View file

@ -90,7 +90,7 @@ fn split_column(args: CommandArgs) -> Result<ActionStream, ShellError> {
))
}
})
.to_action_stream())
.into_action_stream())
}
#[cfg(test)]

Some files were not shown because too many files have changed in this diff Show more