Răsfoiți Sursa

Merge pull request #380 from kornelski/master

Replaced try!() with ?
Benjamin Sago 7 ani în urmă
părinte
comite
55048f7ee2
2 a modificat fișierele cu 7 adăugiri și 7 ștergeri
  1. 2 2
      src/fs/dir.rs
  2. 5 5
      src/options/help.rs

+ 2 - 2
src/fs/dir.rs

@@ -35,9 +35,9 @@ impl Dir {
     pub fn read_dir(path: PathBuf) -> IOResult<Dir> {
         info!("Reading directory {:?}", &path);
 
-        let contents: Vec<PathBuf> = try!(fs::read_dir(&path)?
+        let contents = fs::read_dir(&path)?
                                              .map(|result| result.map(|entry| entry.path()))
-                                             .collect());
+                                             .collect::<Result<_,_>>()?;
 
         Ok(Dir { contents, path })
     }

+ 5 - 5
src/options/help.rs

@@ -96,20 +96,20 @@ impl fmt::Display for HelpString {
     /// Format this help options into an actual string of help
     /// text to be displayed to the user.
     fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
-        try!(write!(f, "Usage:\n  exa [options] [files...]\n"));
+        write!(f, "Usage:\n  exa [options] [files...]\n")?;
 
         if !self.only_long {
-            try!(write!(f, "{}", OPTIONS));
+            write!(f, "{}", OPTIONS)?;
         }
 
-        try!(write!(f, "{}", LONG_OPTIONS));
+        write!(f, "{}", LONG_OPTIONS)?;
 
         if self.git {
-            try!(write!(f, "\n{}", GIT_HELP));
+            write!(f, "\n{}", GIT_HELP)?;
         }
 
         if self.xattrs {
-            try!(write!(f, "\n{}", EXTENDED_HELP));
+            write!(f, "\n{}", EXTENDED_HELP)?;
         }
 
         Ok(())