mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 10:05:54 +02:00
Rust 1.49 Clippy Fixes (#2835)
This commit is contained in:
@ -238,6 +238,7 @@ pub trait WholeStreamCommand: Send + Sync {
|
||||
|
||||
// Custom commands are blocks, so we can use the information in the block to also
|
||||
// implement a WholeStreamCommand
|
||||
#[allow(clippy::suspicious_else_formatting)]
|
||||
#[async_trait]
|
||||
impl WholeStreamCommand for Block {
|
||||
fn name(&self) -> &str {
|
||||
|
@ -35,7 +35,7 @@ fn from_attributes_to_value(attributes: &[roxmltree::Attribute], tag: impl Into<
|
||||
collected.into_value()
|
||||
}
|
||||
|
||||
fn from_node_to_value<'a, 'd>(n: &roxmltree::Node<'a, 'd>, tag: impl Into<Tag>) -> Value {
|
||||
fn from_node_to_value(n: &roxmltree::Node, tag: impl Into<Tag>) -> Value {
|
||||
let tag = tag.into();
|
||||
|
||||
if n.is_element() {
|
||||
|
@ -59,7 +59,7 @@ pub async fn bool_command(args: CommandArgs) -> Result<OutputStream, ShellError>
|
||||
if let Some(prob) = bias {
|
||||
probability = *prob as f64;
|
||||
|
||||
let probability_is_valid = 0.0 <= probability && probability <= 1.0;
|
||||
let probability_is_valid = (0.0..=1.0).contains(&probability);
|
||||
|
||||
if !probability_is_valid {
|
||||
return Err(ShellError::labeled_error(
|
||||
|
@ -197,7 +197,7 @@ async fn seq_dates(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let clone = i.clone();
|
||||
i.to_value(clone.tag)
|
||||
}
|
||||
_ => (1 as i64).to_value_create_tag(),
|
||||
_ => (1_i64).to_value_create_tag(),
|
||||
};
|
||||
|
||||
let day_count: Option<Value> = match days {
|
||||
|
@ -251,7 +251,7 @@ fn process_arguments(range: Value, name: impl Into<Tag>) -> Result<(isize, isize
|
||||
}?;
|
||||
|
||||
let start = match &search {
|
||||
SubstringText(start, _) if start == "" || start == "_" => 0,
|
||||
SubstringText(start, _) if start.is_empty() || start == "_" => 0,
|
||||
SubstringText(start, _) => start.trim().parse().map_err(|_| {
|
||||
ShellError::labeled_error(
|
||||
"could not perform substring",
|
||||
@ -262,7 +262,7 @@ fn process_arguments(range: Value, name: impl Into<Tag>) -> Result<(isize, isize
|
||||
};
|
||||
|
||||
let end = match &search {
|
||||
SubstringText(_, end) if end == "" || end == "_" => isize::max_value(),
|
||||
SubstringText(_, end) if end.is_empty() || end == "_" => isize::max_value(),
|
||||
SubstringText(_, end) => end.trim().parse().map_err(|_| {
|
||||
ShellError::labeled_error(
|
||||
"could not perform substring",
|
||||
|
@ -75,7 +75,7 @@ fn values_to_entries(
|
||||
let mut row: Vec<StyledString> = headers
|
||||
.iter()
|
||||
.map(|d: &StyledString| {
|
||||
if d.contents == "" {
|
||||
if d.contents.is_empty() {
|
||||
match value {
|
||||
Value {
|
||||
value: UntaggedValue::Row(..),
|
||||
|
@ -284,7 +284,7 @@ async fn to_html(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let input: Vec<Value> = input.collect().await;
|
||||
let headers = nu_protocol::merge_descriptors(&input);
|
||||
let headers = Some(headers)
|
||||
.filter(|headers| !headers.is_empty() && (headers.len() > 1 || headers[0] != ""));
|
||||
.filter(|headers| !headers.is_empty() && (headers.len() > 1 || !headers[0].is_empty()));
|
||||
let mut output_string = String::new();
|
||||
let mut regex_hm: HashMap<u32, (&str, String)> = HashMap::new();
|
||||
|
||||
|
@ -59,7 +59,7 @@ async fn to_md(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let mut escaped_headers: Vec<String> = Vec::new();
|
||||
let mut column_widths: Vec<usize> = Vec::new();
|
||||
|
||||
if !headers.is_empty() && (headers.len() > 1 || headers[0] != "") {
|
||||
if !headers.is_empty() && (headers.len() > 1 || !headers[0].is_empty()) {
|
||||
for header in &headers {
|
||||
let escaped_header_string = htmlescape::encode_minimal(&header);
|
||||
column_widths.push(escaped_header_string.len());
|
||||
|
@ -7,7 +7,6 @@ use quick_xml::events::{BytesEnd, BytesStart, BytesText, Event};
|
||||
use std::collections::HashSet;
|
||||
use std::io::Cursor;
|
||||
use std::io::Write;
|
||||
use std::iter::FromIterator;
|
||||
|
||||
pub struct ToXML;
|
||||
|
||||
@ -77,7 +76,7 @@ pub fn get_children(row: &Value) -> Option<&Vec<Value>> {
|
||||
|
||||
pub fn is_xml_row(row: &Value) -> bool {
|
||||
if let UntaggedValue::Row(r) = &row.value {
|
||||
let keys: HashSet<&String> = HashSet::from_iter(r.keys());
|
||||
let keys: HashSet<&String> = r.keys().collect();
|
||||
let children: String = "children".to_string();
|
||||
let attributes: String = "attributes".to_string();
|
||||
return keys.contains(&children) && keys.contains(&attributes) && keys.len() == 2;
|
||||
|
Reference in New Issue
Block a user