Jelajahi Sumber

Replace use of .iter() with reference

Daniel Lockyer 9 tahun lalu
induk
melakukan
da3061d1b3
3 mengubah file dengan 4 tambahan dan 4 penghapusan
  1. 1 1
      src/exa.rs
  2. 1 1
      src/output/details.rs
  3. 2 2
      src/output/grid_details.rs

+ 1 - 1
src/exa.rs

@@ -69,7 +69,7 @@ impl<'w, W: Write + 'w> Exa<'w, W> {
             self.args.push(".".to_owned());
         }
 
-        for file_name in self.args.iter() {
+        for file_name in &self.args {
             match File::from_path(Path::new(&file_name), None) {
                 Err(e) => {
                     writeln!(stderr(), "{}: {}", file_name, e)?;

+ 1 - 1
src/output/details.rs

@@ -481,7 +481,7 @@ impl<'a, U: Users+Groups+'a> Table<'a, U> {
     /// Use the list of columns to find which cells should be produced for
     /// this file, per-column.
     pub fn cells_for_file(&self, file: &File, xattrs: bool) -> Vec<TextCell> {
-        self.columns.clone().iter()
+        self.columns.iter()
                     .map(|c| self.display(file, c, xattrs))
                     .collect()
     }

+ 2 - 2
src/output/grid_details.rs

@@ -122,7 +122,7 @@ impl GridDetails {
 
         if self.grid.across {
             for row in 0 .. height {
-                for column in columns.iter() {
+                for column in &columns {
                     if row < column.len() {
                         let cell = grid::Cell {
                             contents: ANSIStrings(&column[row].contents).to_string(),
@@ -135,7 +135,7 @@ impl GridDetails {
             }
         }
         else {
-            for column in columns.iter() {
+            for column in &columns {
                 for cell in column.iter() {
                     let cell = grid::Cell {
                         contents: ANSIStrings(&cell.contents).to_string(),