Skip to content

Commit

Permalink
clippy: edit apply some pedantic lints
Browse files Browse the repository at this point in the history
warning: consider adding a `;` to the last statement for consistent formatting
  --> src/cmd/edit.rs:73:9
   |
73 |         column_index = Some(headers.len() - 1)
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `column_index = Some(headers.len() - 1);`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
   = note: `-W clippy::semicolon-if-nothing-returned` implied by `-W clippy::pedantic`
   = help: to override `-W clippy::pedantic` add `#[allow(clippy::semicolon_if_nothing_returned)]`

warning: boolean to int conversion using if
  --> src/cmd/edit.rs:89:34
   |
89 |     let mut current_row: usize = if no_headers { 1 } else { 0 };
   |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with from: `usize::from(no_headers)`
   |
   = note: `no_headers as usize` or `no_headers.into()` can also be valid options
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_to_int_with_if
   = note: `-W clippy::bool-to-int-with-if` implied by `-W clippy::pedantic`
   = help: to override `-W clippy::pedantic` add `#[allow(clippy::bool_to_int_with_if)]`
  • Loading branch information
jqnatividad committed Aug 25, 2024
1 parent 9ee84b0 commit 6108416
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cmd/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
let headers = rdr.headers()?;
let mut column_index: Option<usize> = None;
if column == "_" {
column_index = Some(headers.len() - 1)
column_index = Some(headers.len() - 1);
} else if let Ok(c) = column.parse::<usize>() {
column_index = Some(c);
} else {
Expand All @@ -86,6 +86,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
}

let mut record = csv::ByteRecord::new();
#[allow(clippy::bool_to_int_with_if)]
let mut current_row: usize = if no_headers { 1 } else { 0 };
while rdr.read_byte_record(&mut record)? {
if row + 1 == current_row {
Expand Down

0 comments on commit 6108416

Please sign in to comment.