Fix clippy warnings (#4176)

This commit is contained in:
JT 2021-12-03 07:05:38 +13:00 committed by GitHub
parent c00853a473
commit c08e145501
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 277 additions and 264 deletions

477
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,7 +0,0 @@
use derive_new::new;
use nu_protocol::hir;
#[derive(new, Debug)]
pub(crate) struct Command {
pub(crate) args: hir::Call,
}

View file

@ -1,5 +1 @@
mod dynamic;
pub(crate) mod external;
#[allow(unused_imports)]
pub(crate) use dynamic::Command as DynamicCommand;

View file

@ -11,12 +11,6 @@ use nu_protocol::{
pub struct WithEnv;
#[derive(Deserialize, Debug)]
struct WithEnvArgs {
variable: Value,
block: CapturedBlock,
}
impl WholeStreamCommand for WithEnv {
fn name(&self) -> &str {
"with-env"

View file

@ -163,7 +163,7 @@ fn get_current_date() -> (i32, u32, u32) {
fn add_months_of_year_to_table(
args: &CommandArgs,
mut calendar_vec_deque: &mut VecDeque<Value>,
calendar_vec_deque: &mut VecDeque<Value>,
tag: &Tag,
selected_year: i32,
(start_month, end_month): (u32, u32),
@ -181,7 +181,7 @@ fn add_months_of_year_to_table(
let add_month_to_table_result = add_month_to_table(
args,
&mut calendar_vec_deque,
calendar_vec_deque,
tag,
selected_year,
month_number,

View file

@ -6,12 +6,6 @@ use nu_protocol::{Dictionary, Signature, UntaggedValue};
pub struct TermSize;
#[derive(Deserialize, Clone)]
pub struct TermSizeArgs {
wide: bool,
tall: bool,
}
impl WholeStreamCommand for TermSize {
fn name(&self) -> &str {
"term size"

View file

@ -8,22 +8,13 @@ use std::collections::HashMap;
const COMMANDS_DOCS_DIR: &str = "docs/commands";
#[derive(Default)]
pub struct DocumentationConfig {
no_subcommands: bool,
no_color: bool,
brief: bool,
}
impl Default for DocumentationConfig {
fn default() -> Self {
DocumentationConfig {
no_subcommands: false,
no_color: false,
brief: false,
}
}
}
fn generate_doc(name: &str, scope: &Scope) -> IndexMap<String, Value> {
let mut row_entries = IndexMap::new();
let command = scope

View file

@ -34,7 +34,7 @@ impl FileStructure {
self.resources
.iter()
.map(|f| (PathBuf::from(&f.loc), f.at))
.map(|f| to(f))
.map(to)
.collect()
}

View file

@ -33,7 +33,7 @@ pub struct NuError {
pub output: Option<Outcome>,
}
#[derive(Clone, Debug)]
#[derive(Clone, Debug, Default)]
pub struct NuProcess {
pub arguments: Vec<OsString>,
pub environment_vars: Vec<EnvironmentVariable>,
@ -52,16 +52,6 @@ impl fmt::Display for NuProcess {
}
}
impl Default for NuProcess {
fn default() -> Self {
Self {
arguments: vec![],
environment_vars: Vec::default(),
cwd: None,
}
}
}
impl NuProcess {
pub fn arg<T: AsRef<OsStr>>(&mut self, arg: T) -> &mut Self {
self.arguments.push(arg.as_ref().to_os_string());

View file

@ -20,8 +20,7 @@ const DEFAULT_LINE_COLORS: [Color; 5] = [
];
#[derive(Debug)]
pub struct Line<'a> {
title: &'a str,
pub struct Line {
x_labels: Vec<String>,
x_range: [f64; 2],
y_range: [f64; 2],
@ -29,10 +28,9 @@ pub struct Line<'a> {
data: Vec<Vec<(f64, f64)>>,
}
impl<'a> Line<'a> {
pub fn from_model(model: &'a Model) -> Result<Line<'a>, ShellError> {
impl<'a> Line {
pub fn from_model(model: &'a Model) -> Result<Line, ShellError> {
Ok(Line {
title: "Line Chart",
x_labels: model.labels.x.to_vec(),
x_range: [
model.ranges.0.start.as_u64()? as f64,

View file

@ -61,7 +61,7 @@ pub fn value_to_bson_value(v: &Value) -> Result<Bson, ShellError> {
UntaggedValue::Primitive(Primitive::FilePath(s)) => Bson::String(s.display().to_string()),
UntaggedValue::Table(l) => Bson::Array(
l.iter()
.map(|x| value_to_bson_value(x))
.map(value_to_bson_value)
.collect::<Result<_, _>>()?,
),
UntaggedValue::Block(_) | UntaggedValue::Primitive(Primitive::Range(_)) => Bson::Null,

View file

@ -47,7 +47,7 @@ impl TreeView {
_ => value.clone(),
};
builder = builder.begin_child(desc.clone());
Self::from_value_helper(&value, &mut builder);
Self::from_value_helper(&value, builder);
builder = builder.end_child();
//entries.push((desc.name.clone(), value.borrow().copy()))
}