mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 09:45:50 +02:00
Clippy fix for Rust 1.63 (#6299)
Take more sensitive lints into account Somewhat ugly in some cases is the replacement of `.get(0)` with `.first()`
This commit is contained in:
committed by
GitHub
parent
08c98967e0
commit
c2f4969d4f
@ -311,7 +311,7 @@ fn action(
|
||||
Some(dt) => match DateTime::parse_from_str(val, &dt.0) {
|
||||
Ok(d) => Value::Date { val: d, span: head },
|
||||
Err(reason) => {
|
||||
return Value::Error {
|
||||
Value::Error {
|
||||
error: ShellError::CantConvert(
|
||||
format!("could not parse as datetime using format '{}'", dt.0),
|
||||
reason.to_string(),
|
||||
|
@ -145,15 +145,13 @@ fn alias_db(
|
||||
Vec::new(),
|
||||
)),
|
||||
},
|
||||
s => {
|
||||
return Err(ShellError::GenericError(
|
||||
"Connection doesn't define a query".into(),
|
||||
format!("Expected a connection with query. Got {}", s),
|
||||
Some(call.head),
|
||||
None,
|
||||
Vec::new(),
|
||||
))
|
||||
}
|
||||
s => Err(ShellError::GenericError(
|
||||
"Connection doesn't define a query".into(),
|
||||
format!("Expected a connection with query. Got {}", s),
|
||||
Some(call.head),
|
||||
None,
|
||||
Vec::new(),
|
||||
)),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ use super::db_table::DbTable;
|
||||
// Thank you gobang
|
||||
// https://github.com/TaKO8Ki/gobang/blob/main/database-tree/src/lib.rs
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct Db {
|
||||
pub name: String,
|
||||
pub tables: Vec<DbTable>,
|
||||
|
@ -1,6 +1,6 @@
|
||||
use super::db_table::DbTable;
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct DbSchema {
|
||||
pub name: String,
|
||||
pub tables: Vec<DbTable>,
|
||||
|
@ -1,4 +1,4 @@
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
pub struct DbTable {
|
||||
pub name: String,
|
||||
pub create_time: Option<chrono::DateTime<chrono::Utc>>,
|
||||
|
@ -11,7 +11,7 @@ pub mod db_row;
|
||||
pub mod db_schema;
|
||||
pub mod db_table;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
|
||||
pub enum ConnectionDb {
|
||||
Path(PathBuf),
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ impl NuDataFrame {
|
||||
// sorting dataframe by the first column
|
||||
let column_names = self.as_ref().get_column_names();
|
||||
let first_col = column_names
|
||||
.get(0)
|
||||
.first()
|
||||
.expect("already checked that dataframe is different than 0");
|
||||
|
||||
// if unable to sort, then unable to compare
|
||||
|
@ -206,7 +206,7 @@ impl Iterator for DropNthIterator {
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
loop {
|
||||
if let Some(row) = self.rows.get(0) {
|
||||
if let Some(row) = self.rows.first() {
|
||||
if self.current == *row {
|
||||
self.rows.remove(0);
|
||||
self.current += 1;
|
||||
|
@ -207,7 +207,7 @@ impl Iterator for NthIterator {
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
loop {
|
||||
if !self.skip {
|
||||
if let Some(row) = self.rows.get(0) {
|
||||
if let Some(row) = self.rows.first() {
|
||||
if self.current == *row {
|
||||
self.rows.remove(0);
|
||||
self.current += 1;
|
||||
@ -220,7 +220,7 @@ impl Iterator for NthIterator {
|
||||
} else {
|
||||
return None;
|
||||
}
|
||||
} else if let Some(row) = self.rows.get(0) {
|
||||
} else if let Some(row) = self.rows.first() {
|
||||
if self.current == *row {
|
||||
self.rows.remove(0);
|
||||
self.current += 1;
|
||||
|
@ -153,7 +153,7 @@ impl Command for Sort {
|
||||
}
|
||||
|
||||
let iter = vec.into_iter();
|
||||
match &*metadata {
|
||||
match metadata {
|
||||
Some(m) => Ok(iter
|
||||
.into_pipeline_data_with_metadata(m.clone(), engine_state.ctrlc.clone())),
|
||||
None => Ok(iter.into_pipeline_data(engine_state.ctrlc.clone())),
|
||||
|
@ -158,7 +158,7 @@ impl Command for SortBy {
|
||||
}
|
||||
|
||||
let iter = vec.into_iter();
|
||||
match &*metadata {
|
||||
match metadata {
|
||||
Some(m) => {
|
||||
Ok(iter.into_pipeline_data_with_metadata(m.clone(), engine_state.ctrlc.clone()))
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ fn process_range(
|
||||
Value::String { val: s, .. } => {
|
||||
let indexes: Vec<&str> = s.split(',').collect();
|
||||
|
||||
let start_index = indexes.get(0).unwrap_or(&&min_index_str[..]).to_string();
|
||||
let start_index = indexes.first().unwrap_or(&&min_index_str[..]).to_string();
|
||||
|
||||
let end_index = indexes.get(1).unwrap_or(&&max_index_str[..]).to_string();
|
||||
|
||||
|
@ -247,7 +247,7 @@ fn process_arguments(options: &Arguments, head: Span) -> Result<(isize, isize),
|
||||
let idx: Vec<&str> = val.split(',').collect();
|
||||
|
||||
let start = idx
|
||||
.get(0)
|
||||
.first()
|
||||
.ok_or_else(|| {
|
||||
ShellError::UnsupportedInput("could not perform substring".to_string(), head)
|
||||
})?
|
||||
|
Reference in New Issue
Block a user