Skip to content

Commit

Permalink
clippy::explicit_iter_loop
Browse files Browse the repository at this point in the history
warning: it is more concise to loop over references to containers instead of using explicit iteration methods
   --> src/cmd/fetchpost.rs:605:24
    |
605 |         for col_idx in col_list.iter() {
    |                        ^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&*col_list`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop

warning: it is more concise to loop over references to containers instead of using explicit iteration methods
  --> src/cmd/headers.rs:54:23
   |
54 |         for header in rdr.byte_headers()?.iter() {
   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `rdr.byte_headers()?`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop

warning: it is more concise to loop over references to containers instead of using explicit iteration methods
   --> src/cmd/input.rs:156:22
    |
156 |         for field in row.iter() {
    |                      ^^^^^^^^^^ help: to write this more concisely, try: `&row`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop

warning: it is more concise to loop over references to containers instead of using explicit iteration methods
   --> src/cmd/input.rs:177:22
    |
177 |         for field in row.iter() {
    |                      ^^^^^^^^^^ help: to write this more concisely, try: `&row`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop

warning: it is more concise to loop over references to containers instead of using explicit iteration methods
   --> src/cmd/join.rs:183:30
    |
183 |                 for &rowi in rows.iter() {
    |                              ^^^^^^^^^^^ help: to write this more concisely, try: `rows`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop

warning: it is more concise to loop over references to containers instead of using explicit iteration methods
   --> src/cmd/join.rs:208:30
    |
208 |                 for &rowi in rows.iter() {
    |                              ^^^^^^^^^^^ help: to write this more concisely, try: `rows`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop

warning: it is more concise to loop over references to containers instead of using explicit iteration methods
   --> src/cmd/join.rs:262:30
    |
262 |                 for &rowi in rows.iter() {
    |                              ^^^^^^^^^^^ help: to write this more concisely, try: `rows`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop

warning: it is more concise to loop over references to containers instead of using explicit iteration methods
  --> src/cmd/jsonl.rs:46:33
   |
46 |             for (key, value) in map.iter() {
   |                                 ^^^^^^^^^^ help: to write this more concisely, try: `map`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop

warning: it is more concise to loop over references to containers instead of using explicit iteration methods
  --> src/cmd/jsonl.rs:86:16
   |
86 |     for key in path.iter() {
   |                ^^^^^^^^^^^ help: to write this more concisely, try: `path`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop

warning: it is more concise to loop over references to containers instead of using explicit iteration methods
   --> src/cmd/safenames.rs:208:28
    |
208 |         for header_name in headers.iter() {
    |                            ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&headers`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop

warning: it is more concise to loop over references to containers instead of using explicit iteration methods
   --> src/cmd/schema.rs:163:36
    |
163 |     for (field_name, field_def) in properties_map.iter_mut() {
    |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut properties_map`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop

warning: it is more concise to loop over references to containers instead of using explicit iteration methods
   --> src/cmd/schema.rs:761:32
    |
761 |     for (header, value_set) in unique_values_map.iter() {
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&unique_values_map`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop

warning: it is more concise to loop over references to containers instead of using explicit iteration methods
   --> src/cmd/tojsonl.rs:152:37
    |
152 |     for (_field_name, field_def) in properties_map.iter() {
    |                                     ^^^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&properties_map`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop

warning: it is more concise to loop over references to containers instead of using explicit iteration methods
   --> src/cmd/validate.rs:166:34
    |
166 |                     for field in fields.iter() {
    |                                  ^^^^^^^^^^^^^ help: to write this more concisely, try: `fields`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop
  • Loading branch information
jqnatividad committed Jul 3, 2023
1 parent 4586da8 commit 9d0aacf
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/cmd/fetchpost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {

// construct body per the column-list
form_body_jsonmap.clear();
for col_idx in col_list.iter() {
for col_idx in &*col_list {
let header_key = String::from_utf8_lossy(headers.get(*col_idx).unwrap());
let value_string = from_utf8(&record[*col_idx]).unwrap_or_default().to_string();
form_body_jsonmap.insert(
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
let mut headers: Vec<Vec<u8>> = vec![];
for conf in configs {
let mut rdr = conf.reader()?;
for header in rdr.byte_headers()?.iter() {
for header in rdr.byte_headers()? {
if !args.flag_intersect || !headers.iter().any(|h| &**h == header) {
headers.push(header.to_vec());
}
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
rdr.read_byte_record(&mut row)?;
row.trim();

for field in row.iter() {
for field in &row {
// we also trim excess quotes from the header, to be consistent with safenames
str_row.push_field(String::from_utf8_lossy(field).trim_matches('"'));
}
Expand All @@ -174,7 +174,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
};

str_row.clear();
for field in row.iter() {
for field in &row {
if let Ok(utf8_field) = simdutf8::basic::from_utf8(field) {
str_row.push_field(utf8_field);
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl<R: io::Read + io::Seek, W: io::Write> IoState<R, W> {
let row = row?;
let key = get_row_key(&self.sel1, &row, self.casei);
if let Some(rows) = validx.values.get(&key) {
for &rowi in rows.iter() {
for &rowi in rows {
validx.idx.seek(rowi as u64)?;

validx.idx.read_byte_record(&mut scratch)?;
Expand All @@ -205,7 +205,7 @@ impl<R: io::Read + io::Seek, W: io::Write> IoState<R, W> {
let row = row?;
let key = get_row_key(&self.sel1, &row, self.casei);
if let Some(rows) = validx.values.get(&key) {
for &rowi in rows.iter() {
for &rowi in rows {
validx.idx.seek(rowi as u64)?;
let row1 = row.iter();
validx.idx.read_byte_record(&mut scratch)?;
Expand Down Expand Up @@ -259,7 +259,7 @@ impl<R: io::Read + io::Seek, W: io::Write> IoState<R, W> {
let row1 = row1?;
let key = get_row_key(&self.sel1, &row1, self.casei);
if let Some(rows) = validx.values.get(&key) {
for &rowi in rows.iter() {
for &rowi in rows {
rdr2_written[rowi] = true;

validx.idx.seek(rowi as u64)?;
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/jsonl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct Args {
fn recurse_to_infer_headers(value: &Value, headers: &mut Vec<Vec<String>>, path: Vec<String>) {
match value {
Value::Object(map) => {
for (key, value) in map.iter() {
for (key, value) in map {
match value {
Value::Null
| Value::Bool(_)
Expand Down Expand Up @@ -83,7 +83,7 @@ fn infer_headers(value: &Value) -> Vec<Vec<String>> {
fn get_value_at_path(value: &Value, path: &[String]) -> Option<Value> {
let mut current = value;

for key in path.iter() {
for key in path {
match current.get(key) {
Some(new_value) => {
current = new_value;
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/safenames.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
let mut checkednames_map: HashMap<String, u16, RandomState> = HashMap::default();
let mut temp_string;

for header_name in headers.iter() {
for header_name in &headers {
if safe_headers.contains(&header_name.to_string()) {
if !safenames_vec.contains(&header_name.to_string()) {
safenames_vec.push(header_name.to_string());
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
let pattern_map = generate_string_patterns(&args, &properties_map)?;

// enrich properties map with pattern constraint for String fields
for (field_name, field_def) in properties_map.iter_mut() {
for (field_name, field_def) in &mut properties_map {
// dbg!(&field_name, &field_def);
if pattern_map.contains_key(field_name) && should_emit_pattern_constraint(field_def) {
let field_def_map = field_def.as_object_mut().unwrap();
Expand Down Expand Up @@ -758,7 +758,7 @@ fn generate_string_patterns(

// build regex pattern for each header
pattern_map.reserve(unique_values_map.len());
for (header, value_set) in unique_values_map.iter() {
for (header, value_set) in &unique_values_map {
// Convert Set to Vector
let values: Vec<&String> = Vec::from_iter(value_set);

Expand Down
2 changes: 1 addition & 1 deletion src/cmd/tojsonl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {

// create a vec lookup about inferred field data types
let mut field_type_vec: Vec<JsonlType> = Vec::with_capacity(headers.len());
for (_field_name, field_def) in properties_map.iter() {
for (_field_name, field_def) in &properties_map {
let Some(field_map) = field_def.as_object() else {
return fail!("Cannot create field map");
};
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
match fields_result {
Ok(fields) => {
header_len = fields.len();
for field in fields.iter() {
for field in fields {
field_vec.push(field.to_string());
}
let field_list = field_vec.join(r#"", ""#);
Expand Down

0 comments on commit 9d0aacf

Please sign in to comment.