@@ -42,8 +42,8 @@ use time::SystemTime;
4242/// use std::io::prelude::*;
4343///
4444/// # fn foo() -> std::io::Result<()> {
45- /// let mut file = try!( File::create("foo.txt")) ;
46- /// try!( file.write_all(b"Hello, world!")) ;
45+ /// let mut file = File::create("foo.txt")? ;
46+ /// file.write_all(b"Hello, world!")? ;
4747/// # Ok(())
4848/// # }
4949/// ```
@@ -55,9 +55,9 @@ use time::SystemTime;
5555/// use std::io::prelude::*;
5656///
5757/// # fn foo() -> std::io::Result<()> {
58- /// let mut file = try!( File::open("foo.txt")) ;
58+ /// let mut file = File::open("foo.txt")? ;
5959/// let mut contents = String::new();
60- /// try!( file.read_to_string(&mut contents)) ;
60+ /// file.read_to_string(&mut contents)? ;
6161/// assert_eq!(contents, "Hello, world!");
6262/// # Ok(())
6363/// # }
@@ -72,10 +72,10 @@ use time::SystemTime;
7272/// use std::io::prelude::*;
7373///
7474/// # fn foo() -> std::io::Result<()> {
75- /// let file = try!( File::open("foo.txt")) ;
75+ /// let file = File::open("foo.txt")? ;
7676/// let mut buf_reader = BufReader::new(file);
7777/// let mut contents = String::new();
78- /// try!( buf_reader.read_to_string(&mut contents)) ;
78+ /// buf_reader.read_to_string(&mut contents)? ;
7979/// assert_eq!(contents, "Hello, world!");
8080/// # Ok(())
8181/// # }
@@ -227,7 +227,7 @@ impl File {
227227 /// use std::fs::File;
228228 ///
229229 /// # fn foo() -> std::io::Result<()> {
230- /// let mut f = try!( File::open("foo.txt")) ;
230+ /// let mut f = File::open("foo.txt")? ;
231231 /// # Ok(())
232232 /// # }
233233 /// ```
@@ -251,7 +251,7 @@ impl File {
251251 /// use std::fs::File;
252252 ///
253253 /// # fn foo() -> std::io::Result<()> {
254- /// let mut f = try!( File::create("foo.txt")) ;
254+ /// let mut f = File::create("foo.txt")? ;
255255 /// # Ok(())
256256 /// # }
257257 /// ```
@@ -272,10 +272,10 @@ impl File {
272272 /// use std::io::prelude::*;
273273 ///
274274 /// # fn foo() -> std::io::Result<()> {
275- /// let mut f = try!( File::create("foo.txt")) ;
276- /// try!( f.write_all(b"Hello, world!")) ;
275+ /// let mut f = File::create("foo.txt")? ;
276+ /// f.write_all(b"Hello, world!")? ;
277277 ///
278- /// try!( f.sync_all()) ;
278+ /// f.sync_all()? ;
279279 /// # Ok(())
280280 /// # }
281281 /// ```
@@ -303,10 +303,10 @@ impl File {
303303 /// use std::io::prelude::*;
304304 ///
305305 /// # fn foo() -> std::io::Result<()> {
306- /// let mut f = try!( File::create("foo.txt")) ;
307- /// try!( f.write_all(b"Hello, world!")) ;
306+ /// let mut f = File::create("foo.txt")? ;
307+ /// f.write_all(b"Hello, world!")? ;
308308 ///
309- /// try!( f.sync_data()) ;
309+ /// f.sync_data()? ;
310310 /// # Ok(())
311311 /// # }
312312 /// ```
@@ -333,8 +333,8 @@ impl File {
333333 /// use std::fs::File;
334334 ///
335335 /// # fn foo() -> std::io::Result<()> {
336- /// let mut f = try!( File::create("foo.txt")) ;
337- /// try!( f.set_len(10)) ;
336+ /// let mut f = File::create("foo.txt")? ;
337+ /// f.set_len(10)? ;
338338 /// # Ok(())
339339 /// # }
340340 /// ```
@@ -351,8 +351,8 @@ impl File {
351351 /// use std::fs::File;
352352 ///
353353 /// # fn foo() -> std::io::Result<()> {
354- /// let mut f = try!( File::open("foo.txt")) ;
355- /// let metadata = try!( f.metadata()) ;
354+ /// let mut f = File::open("foo.txt")? ;
355+ /// let metadata = f.metadata()? ;
356356 /// # Ok(())
357357 /// # }
358358 /// ```
@@ -373,8 +373,8 @@ impl File {
373373 /// use std::fs::File;
374374 ///
375375 /// # fn foo() -> std::io::Result<()> {
376- /// let mut f = try!( File::open("foo.txt")) ;
377- /// let file_copy = try!( f.try_clone()) ;
376+ /// let mut f = File::open("foo.txt")? ;
377+ /// let file_copy = f.try_clone()? ;
378378 /// # Ok(())
379379 /// # }
380380 /// ```
@@ -691,7 +691,7 @@ impl Metadata {
691691 /// # fn foo() -> std::io::Result<()> {
692692 /// use std::fs;
693693 ///
694- /// let metadata = try!( fs::metadata("foo.txt")) ;
694+ /// let metadata = fs::metadata("foo.txt")? ;
695695 ///
696696 /// println!("{:?}", metadata.file_type());
697697 /// # Ok(())
@@ -710,7 +710,7 @@ impl Metadata {
710710 /// # fn foo() -> std::io::Result<()> {
711711 /// use std::fs;
712712 ///
713- /// let metadata = try!( fs::metadata("foo.txt")) ;
713+ /// let metadata = fs::metadata("foo.txt")? ;
714714 ///
715715 /// assert!(!metadata.is_dir());
716716 /// # Ok(())
@@ -727,7 +727,7 @@ impl Metadata {
727727 /// # fn foo() -> std::io::Result<()> {
728728 /// use std::fs;
729729 ///
730- /// let metadata = try!( fs::metadata("foo.txt")) ;
730+ /// let metadata = fs::metadata("foo.txt")? ;
731731 ///
732732 /// assert!(metadata.is_file());
733733 /// # Ok(())
@@ -744,7 +744,7 @@ impl Metadata {
744744 /// # fn foo() -> std::io::Result<()> {
745745 /// use std::fs;
746746 ///
747- /// let metadata = try!( fs::metadata("foo.txt")) ;
747+ /// let metadata = fs::metadata("foo.txt")? ;
748748 ///
749749 /// assert_eq!(0, metadata.len());
750750 /// # Ok(())
@@ -761,7 +761,7 @@ impl Metadata {
761761 /// # fn foo() -> std::io::Result<()> {
762762 /// use std::fs;
763763 ///
764- /// let metadata = try!( fs::metadata("foo.txt")) ;
764+ /// let metadata = fs::metadata("foo.txt")? ;
765765 ///
766766 /// assert!(!metadata.permissions().readonly());
767767 /// # Ok(())
@@ -788,7 +788,7 @@ impl Metadata {
788788 /// # fn foo() -> std::io::Result<()> {
789789 /// use std::fs;
790790 ///
791- /// let metadata = try!( fs::metadata("foo.txt")) ;
791+ /// let metadata = fs::metadata("foo.txt")? ;
792792 ///
793793 /// if let Ok(time) = metadata.modified() {
794794 /// println!("{:?}", time);
@@ -823,7 +823,7 @@ impl Metadata {
823823 /// # fn foo() -> std::io::Result<()> {
824824 /// use std::fs;
825825 ///
826- /// let metadata = try!( fs::metadata("foo.txt")) ;
826+ /// let metadata = fs::metadata("foo.txt")? ;
827827 ///
828828 /// if let Ok(time) = metadata.accessed() {
829829 /// println!("{:?}", time);
@@ -854,7 +854,7 @@ impl Metadata {
854854 /// # fn foo() -> std::io::Result<()> {
855855 /// use std::fs;
856856 ///
857- /// let metadata = try!( fs::metadata("foo.txt")) ;
857+ /// let metadata = fs::metadata("foo.txt")? ;
858858 ///
859859 /// if let Ok(time) = metadata.created() {
860860 /// println!("{:?}", time);
@@ -898,8 +898,8 @@ impl Permissions {
898898 /// use std::fs::File;
899899 ///
900900 /// # fn foo() -> std::io::Result<()> {
901- /// let mut f = try!( File::create("foo.txt")) ;
902- /// let metadata = try!( f.metadata()) ;
901+ /// let mut f = File::create("foo.txt")? ;
902+ /// let metadata = f.metadata()? ;
903903 ///
904904 /// assert_eq!(false, metadata.permissions().readonly());
905905 /// # Ok(())
@@ -919,8 +919,8 @@ impl Permissions {
919919 /// use std::fs::File;
920920 ///
921921 /// # fn foo() -> std::io::Result<()> {
922- /// let f = try!( File::create("foo.txt")) ;
923- /// let metadata = try!( f.metadata()) ;
922+ /// let f = File::create("foo.txt")? ;
923+ /// let metadata = f.metadata()? ;
924924 /// let mut permissions = metadata.permissions();
925925 ///
926926 /// permissions.set_readonly(true);
@@ -948,7 +948,7 @@ impl FileType {
948948 /// # fn foo() -> std::io::Result<()> {
949949 /// use std::fs;
950950 ///
951- /// let metadata = try!( fs::metadata("foo.txt")) ;
951+ /// let metadata = fs::metadata("foo.txt")? ;
952952 /// let file_type = metadata.file_type();
953953 ///
954954 /// assert_eq!(file_type.is_dir(), false);
@@ -966,7 +966,7 @@ impl FileType {
966966 /// # fn foo() -> std::io::Result<()> {
967967 /// use std::fs;
968968 ///
969- /// let metadata = try!( fs::metadata("foo.txt")) ;
969+ /// let metadata = fs::metadata("foo.txt")? ;
970970 /// let file_type = metadata.file_type();
971971 ///
972972 /// assert_eq!(file_type.is_file(), true);
@@ -995,7 +995,7 @@ impl FileType {
995995 /// # fn foo() -> std::io::Result<()> {
996996 /// use std::fs;
997997 ///
998- /// let metadata = try!( fs::symlink_metadata("foo.txt")) ;
998+ /// let metadata = fs::symlink_metadata("foo.txt")? ;
999999 /// let file_type = metadata.file_type();
10001000 ///
10011001 /// assert_eq!(file_type.is_symlink(), false);
@@ -1040,8 +1040,8 @@ impl DirEntry {
10401040 /// ```
10411041 /// use std::fs;
10421042 /// # fn foo() -> std::io::Result<()> {
1043- /// for entry in try!( fs::read_dir(".")) {
1044- /// let dir = try!( entry) ;
1043+ /// for entry in fs::read_dir(".")? {
1044+ /// let dir = entry? ;
10451045 /// println!("{:?}", dir.path());
10461046 /// }
10471047 /// # Ok(())
@@ -1193,7 +1193,7 @@ impl AsInner<fs_imp::DirEntry> for DirEntry {
11931193/// use std::fs;
11941194///
11951195/// # fn foo() -> std::io::Result<()> {
1196- /// try!( fs::remove_file("a.txt")) ;
1196+ /// fs::remove_file("a.txt")? ;
11971197/// # Ok(())
11981198/// # }
11991199/// ```
@@ -1229,7 +1229,7 @@ pub fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
12291229/// # fn foo() -> std::io::Result<()> {
12301230/// use std::fs;
12311231///
1232- /// let attr = try!( fs::metadata("/some/file/path.txt")) ;
1232+ /// let attr = fs::metadata("/some/file/path.txt")? ;
12331233/// // inspect attr ...
12341234/// # Ok(())
12351235/// # }
@@ -1262,7 +1262,7 @@ pub fn metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
12621262/// # fn foo() -> std::io::Result<()> {
12631263/// use std::fs;
12641264///
1265- /// let attr = try!( fs::symlink_metadata("/some/file/path.txt")) ;
1265+ /// let attr = fs::symlink_metadata("/some/file/path.txt")? ;
12661266/// // inspect attr ...
12671267/// # Ok(())
12681268/// # }
@@ -1305,7 +1305,7 @@ pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
13051305/// use std::fs;
13061306///
13071307/// # fn foo() -> std::io::Result<()> {
1308- /// try!( fs::rename("a.txt", "b.txt")) ; // Rename a.txt to b.txt
1308+ /// fs::rename("a.txt", "b.txt")? ; // Rename a.txt to b.txt
13091309/// # Ok(())
13101310/// # }
13111311/// ```
@@ -1349,7 +1349,7 @@ pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()>
13491349/// use std::fs;
13501350///
13511351/// # fn foo() -> std::io::Result<()> {
1352- /// try!( fs::copy("foo.txt", "bar.txt")) ; // Copy foo.txt to bar.txt
1352+ /// fs::copy("foo.txt", "bar.txt")? ; // Copy foo.txt to bar.txt
13531353/// # Ok(()) }
13541354/// ```
13551355#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -1382,7 +1382,7 @@ pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<u64> {
13821382/// use std::fs;
13831383///
13841384/// # fn foo() -> std::io::Result<()> {
1385- /// try!( fs::hard_link("a.txt", "b.txt")) ; // Hard link a.txt to b.txt
1385+ /// fs::hard_link("a.txt", "b.txt")? ; // Hard link a.txt to b.txt
13861386/// # Ok(())
13871387/// # }
13881388/// ```
@@ -1405,7 +1405,7 @@ pub fn hard_link<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<(
14051405/// use std::fs;
14061406///
14071407/// # fn foo() -> std::io::Result<()> {
1408- /// try!( fs::soft_link("a.txt", "b.txt")) ;
1408+ /// fs::soft_link("a.txt", "b.txt")? ;
14091409/// # Ok(())
14101410/// # }
14111411/// ```
@@ -1441,7 +1441,7 @@ pub fn soft_link<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<(
14411441/// use std::fs;
14421442///
14431443/// # fn foo() -> std::io::Result<()> {
1444- /// let path = try!( fs::read_link("a.txt")) ;
1444+ /// let path = fs::read_link("a.txt")? ;
14451445/// # Ok(())
14461446/// # }
14471447/// ```
@@ -1474,7 +1474,7 @@ pub fn read_link<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
14741474/// use std::fs;
14751475///
14761476/// # fn foo() -> std::io::Result<()> {
1477- /// let path = try!( fs::canonicalize("../a/../foo.txt")) ;
1477+ /// let path = fs::canonicalize("../a/../foo.txt")? ;
14781478/// # Ok(())
14791479/// # }
14801480/// ```
@@ -1506,7 +1506,7 @@ pub fn canonicalize<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
15061506/// use std::fs;
15071507///
15081508/// # fn foo() -> std::io::Result<()> {
1509- /// try!( fs::create_dir("/some/dir")) ;
1509+ /// fs::create_dir("/some/dir")? ;
15101510/// # Ok(())
15111511/// # }
15121512/// ```
@@ -1541,7 +1541,7 @@ pub fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
15411541/// use std::fs;
15421542///
15431543/// # fn foo() -> std::io::Result<()> {
1544- /// try!( fs::create_dir_all("/some/dir")) ;
1544+ /// fs::create_dir_all("/some/dir")? ;
15451545/// # Ok(())
15461546/// # }
15471547/// ```
@@ -1573,7 +1573,7 @@ pub fn create_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
15731573/// use std::fs;
15741574///
15751575/// # fn foo() -> std::io::Result<()> {
1576- /// try!( fs::remove_dir("/some/dir")) ;
1576+ /// fs::remove_dir("/some/dir")? ;
15771577/// # Ok(())
15781578/// # }
15791579/// ```
@@ -1606,7 +1606,7 @@ pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
16061606/// use std::fs;
16071607///
16081608/// # fn foo() -> std::io::Result<()> {
1609- /// try!( fs::remove_dir_all("/some/dir")) ;
1609+ /// fs::remove_dir_all("/some/dir")? ;
16101610/// # Ok(())
16111611/// # }
16121612/// ```
@@ -1649,11 +1649,11 @@ pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
16491649/// // one possible implementation of walking a directory only visiting files
16501650/// fn visit_dirs(dir: &Path, cb: &Fn(&DirEntry)) -> io::Result<()> {
16511651/// if dir.is_dir() {
1652- /// for entry in try!( fs::read_dir(dir)) {
1653- /// let entry = try!( entry) ;
1652+ /// for entry in fs::read_dir(dir)? {
1653+ /// let entry = entry? ;
16541654/// let path = entry.path();
16551655/// if path.is_dir() {
1656- /// try!( visit_dirs(&path, cb)) ;
1656+ /// visit_dirs(&path, cb)? ;
16571657/// } else {
16581658/// cb(&entry);
16591659/// }
@@ -1690,9 +1690,9 @@ pub fn read_dir<P: AsRef<Path>>(path: P) -> io::Result<ReadDir> {
16901690/// # fn foo() -> std::io::Result<()> {
16911691/// use std::fs;
16921692///
1693- /// let mut perms = try!( fs::metadata("foo.txt")) .permissions();
1693+ /// let mut perms = fs::metadata("foo.txt")? .permissions();
16941694/// perms.set_readonly(true);
1695- /// try!( fs::set_permissions("foo.txt", perms)) ;
1695+ /// fs::set_permissions("foo.txt", perms)? ;
16961696/// # Ok(())
16971697/// # }
16981698/// ```
0 commit comments