mirror of
https://github.com/nushell/nushell.git
synced 2024-12-23 15:39:06 +01:00
Deal with needless_collect
with annotations
This commit is contained in:
parent
07c21a58fb
commit
05aca98445
@ -235,6 +235,8 @@ impl Command for Cp {
|
|||||||
})?
|
})?
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// The lint does not properly take into account trait bounds
|
||||||
|
// `ExactSizedIterator` and `DoubleEndedIterator` are necessary to `.rev()` twice with `.take()` inbetween
|
||||||
#[allow(clippy::needless_collect)]
|
#[allow(clippy::needless_collect)]
|
||||||
let comps: Vec<_> = path
|
let comps: Vec<_> = path
|
||||||
.components()
|
.components()
|
||||||
|
@ -34,10 +34,6 @@ impl Command for Lines {
|
|||||||
let ctrlc = engine_state.ctrlc.clone();
|
let ctrlc = engine_state.ctrlc.clone();
|
||||||
let skip_empty = call.has_flag("skip-empty");
|
let skip_empty = call.has_flag("skip-empty");
|
||||||
match input {
|
match input {
|
||||||
#[allow(clippy::needless_collect)]
|
|
||||||
// Collect is needed because the string may not live long enough for
|
|
||||||
// the Rc structure to continue using it. If split could take ownership
|
|
||||||
// of the split values, then this wouldn't be needed
|
|
||||||
PipelineData::Value(Value::String { val, span }, ..) => {
|
PipelineData::Value(Value::String { val, span }, ..) => {
|
||||||
let split_char = if val.contains("\r\n") { "\r\n" } else { "\n" };
|
let split_char = if val.contains("\r\n") { "\r\n" } else { "\n" };
|
||||||
|
|
||||||
|
@ -50,6 +50,9 @@ impl Command for Reverse {
|
|||||||
) -> Result<PipelineData, ShellError> {
|
) -> Result<PipelineData, ShellError> {
|
||||||
let metadata = input.metadata();
|
let metadata = input.metadata();
|
||||||
|
|
||||||
|
// Collecting has to be allowed as `PipelineData` does not implement `DoubleEndedIterator`
|
||||||
|
// The lint seems broken in those aspects:
|
||||||
|
// https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+needless_collect
|
||||||
#[allow(clippy::needless_collect)]
|
#[allow(clippy::needless_collect)]
|
||||||
let v: Vec<_> = input.into_iter().collect();
|
let v: Vec<_> = input.into_iter().collect();
|
||||||
let iter = v.into_iter().rev();
|
let iter = v.into_iter().rev();
|
||||||
|
Loading…
Reference in New Issue
Block a user