@@ -42,8 +42,8 @@ use time::SystemTime;
42
42
/// use std::io::prelude::*;
43
43
///
44
44
/// # 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!")? ;
47
47
/// # Ok(())
48
48
/// # }
49
49
/// ```
@@ -55,9 +55,9 @@ use time::SystemTime;
55
55
/// use std::io::prelude::*;
56
56
///
57
57
/// # fn foo() -> std::io::Result<()> {
58
- /// let mut file = try!( File::open("foo.txt")) ;
58
+ /// let mut file = File::open("foo.txt")? ;
59
59
/// let mut contents = String::new();
60
- /// try!( file.read_to_string(&mut contents)) ;
60
+ /// file.read_to_string(&mut contents)? ;
61
61
/// assert_eq!(contents, "Hello, world!");
62
62
/// # Ok(())
63
63
/// # }
@@ -72,10 +72,10 @@ use time::SystemTime;
72
72
/// use std::io::prelude::*;
73
73
///
74
74
/// # fn foo() -> std::io::Result<()> {
75
- /// let file = try!( File::open("foo.txt")) ;
75
+ /// let file = File::open("foo.txt")? ;
76
76
/// let mut buf_reader = BufReader::new(file);
77
77
/// let mut contents = String::new();
78
- /// try!( buf_reader.read_to_string(&mut contents)) ;
78
+ /// buf_reader.read_to_string(&mut contents)? ;
79
79
/// assert_eq!(contents, "Hello, world!");
80
80
/// # Ok(())
81
81
/// # }
@@ -227,7 +227,7 @@ impl File {
227
227
/// use std::fs::File;
228
228
///
229
229
/// # fn foo() -> std::io::Result<()> {
230
- /// let mut f = try!( File::open("foo.txt")) ;
230
+ /// let mut f = File::open("foo.txt")? ;
231
231
/// # Ok(())
232
232
/// # }
233
233
/// ```
@@ -251,7 +251,7 @@ impl File {
251
251
/// use std::fs::File;
252
252
///
253
253
/// # fn foo() -> std::io::Result<()> {
254
- /// let mut f = try!( File::create("foo.txt")) ;
254
+ /// let mut f = File::create("foo.txt")? ;
255
255
/// # Ok(())
256
256
/// # }
257
257
/// ```
@@ -272,10 +272,10 @@ impl File {
272
272
/// use std::io::prelude::*;
273
273
///
274
274
/// # 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!")? ;
277
277
///
278
- /// try!( f.sync_all()) ;
278
+ /// f.sync_all()? ;
279
279
/// # Ok(())
280
280
/// # }
281
281
/// ```
@@ -303,10 +303,10 @@ impl File {
303
303
/// use std::io::prelude::*;
304
304
///
305
305
/// # 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!")? ;
308
308
///
309
- /// try!( f.sync_data()) ;
309
+ /// f.sync_data()? ;
310
310
/// # Ok(())
311
311
/// # }
312
312
/// ```
@@ -333,8 +333,8 @@ impl File {
333
333
/// use std::fs::File;
334
334
///
335
335
/// # 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)? ;
338
338
/// # Ok(())
339
339
/// # }
340
340
/// ```
@@ -351,8 +351,8 @@ impl File {
351
351
/// use std::fs::File;
352
352
///
353
353
/// # 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()? ;
356
356
/// # Ok(())
357
357
/// # }
358
358
/// ```
@@ -373,8 +373,8 @@ impl File {
373
373
/// use std::fs::File;
374
374
///
375
375
/// # 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()? ;
378
378
/// # Ok(())
379
379
/// # }
380
380
/// ```
@@ -691,7 +691,7 @@ impl Metadata {
691
691
/// # fn foo() -> std::io::Result<()> {
692
692
/// use std::fs;
693
693
///
694
- /// let metadata = try!( fs::metadata("foo.txt")) ;
694
+ /// let metadata = fs::metadata("foo.txt")? ;
695
695
///
696
696
/// println!("{:?}", metadata.file_type());
697
697
/// # Ok(())
@@ -710,7 +710,7 @@ impl Metadata {
710
710
/// # fn foo() -> std::io::Result<()> {
711
711
/// use std::fs;
712
712
///
713
- /// let metadata = try!( fs::metadata("foo.txt")) ;
713
+ /// let metadata = fs::metadata("foo.txt")? ;
714
714
///
715
715
/// assert!(!metadata.is_dir());
716
716
/// # Ok(())
@@ -727,7 +727,7 @@ impl Metadata {
727
727
/// # fn foo() -> std::io::Result<()> {
728
728
/// use std::fs;
729
729
///
730
- /// let metadata = try!( fs::metadata("foo.txt")) ;
730
+ /// let metadata = fs::metadata("foo.txt")? ;
731
731
///
732
732
/// assert!(metadata.is_file());
733
733
/// # Ok(())
@@ -744,7 +744,7 @@ impl Metadata {
744
744
/// # fn foo() -> std::io::Result<()> {
745
745
/// use std::fs;
746
746
///
747
- /// let metadata = try!( fs::metadata("foo.txt")) ;
747
+ /// let metadata = fs::metadata("foo.txt")? ;
748
748
///
749
749
/// assert_eq!(0, metadata.len());
750
750
/// # Ok(())
@@ -761,7 +761,7 @@ impl Metadata {
761
761
/// # fn foo() -> std::io::Result<()> {
762
762
/// use std::fs;
763
763
///
764
- /// let metadata = try!( fs::metadata("foo.txt")) ;
764
+ /// let metadata = fs::metadata("foo.txt")? ;
765
765
///
766
766
/// assert!(!metadata.permissions().readonly());
767
767
/// # Ok(())
@@ -788,7 +788,7 @@ impl Metadata {
788
788
/// # fn foo() -> std::io::Result<()> {
789
789
/// use std::fs;
790
790
///
791
- /// let metadata = try!( fs::metadata("foo.txt")) ;
791
+ /// let metadata = fs::metadata("foo.txt")? ;
792
792
///
793
793
/// if let Ok(time) = metadata.modified() {
794
794
/// println!("{:?}", time);
@@ -823,7 +823,7 @@ impl Metadata {
823
823
/// # fn foo() -> std::io::Result<()> {
824
824
/// use std::fs;
825
825
///
826
- /// let metadata = try!( fs::metadata("foo.txt")) ;
826
+ /// let metadata = fs::metadata("foo.txt")? ;
827
827
///
828
828
/// if let Ok(time) = metadata.accessed() {
829
829
/// println!("{:?}", time);
@@ -854,7 +854,7 @@ impl Metadata {
854
854
/// # fn foo() -> std::io::Result<()> {
855
855
/// use std::fs;
856
856
///
857
- /// let metadata = try!( fs::metadata("foo.txt")) ;
857
+ /// let metadata = fs::metadata("foo.txt")? ;
858
858
///
859
859
/// if let Ok(time) = metadata.created() {
860
860
/// println!("{:?}", time);
@@ -898,8 +898,8 @@ impl Permissions {
898
898
/// use std::fs::File;
899
899
///
900
900
/// # 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()? ;
903
903
///
904
904
/// assert_eq!(false, metadata.permissions().readonly());
905
905
/// # Ok(())
@@ -919,8 +919,8 @@ impl Permissions {
919
919
/// use std::fs::File;
920
920
///
921
921
/// # 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()? ;
924
924
/// let mut permissions = metadata.permissions();
925
925
///
926
926
/// permissions.set_readonly(true);
@@ -948,7 +948,7 @@ impl FileType {
948
948
/// # fn foo() -> std::io::Result<()> {
949
949
/// use std::fs;
950
950
///
951
- /// let metadata = try!( fs::metadata("foo.txt")) ;
951
+ /// let metadata = fs::metadata("foo.txt")? ;
952
952
/// let file_type = metadata.file_type();
953
953
///
954
954
/// assert_eq!(file_type.is_dir(), false);
@@ -966,7 +966,7 @@ impl FileType {
966
966
/// # fn foo() -> std::io::Result<()> {
967
967
/// use std::fs;
968
968
///
969
- /// let metadata = try!( fs::metadata("foo.txt")) ;
969
+ /// let metadata = fs::metadata("foo.txt")? ;
970
970
/// let file_type = metadata.file_type();
971
971
///
972
972
/// assert_eq!(file_type.is_file(), true);
@@ -995,7 +995,7 @@ impl FileType {
995
995
/// # fn foo() -> std::io::Result<()> {
996
996
/// use std::fs;
997
997
///
998
- /// let metadata = try!( fs::symlink_metadata("foo.txt")) ;
998
+ /// let metadata = fs::symlink_metadata("foo.txt")? ;
999
999
/// let file_type = metadata.file_type();
1000
1000
///
1001
1001
/// assert_eq!(file_type.is_symlink(), false);
@@ -1040,8 +1040,8 @@ impl DirEntry {
1040
1040
/// ```
1041
1041
/// use std::fs;
1042
1042
/// # 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? ;
1045
1045
/// println!("{:?}", dir.path());
1046
1046
/// }
1047
1047
/// # Ok(())
@@ -1193,7 +1193,7 @@ impl AsInner<fs_imp::DirEntry> for DirEntry {
1193
1193
/// use std::fs;
1194
1194
///
1195
1195
/// # fn foo() -> std::io::Result<()> {
1196
- /// try!( fs::remove_file("a.txt")) ;
1196
+ /// fs::remove_file("a.txt")? ;
1197
1197
/// # Ok(())
1198
1198
/// # }
1199
1199
/// ```
@@ -1229,7 +1229,7 @@ pub fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
1229
1229
/// # fn foo() -> std::io::Result<()> {
1230
1230
/// use std::fs;
1231
1231
///
1232
- /// let attr = try!( fs::metadata("/some/file/path.txt")) ;
1232
+ /// let attr = fs::metadata("/some/file/path.txt")? ;
1233
1233
/// // inspect attr ...
1234
1234
/// # Ok(())
1235
1235
/// # }
@@ -1262,7 +1262,7 @@ pub fn metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
1262
1262
/// # fn foo() -> std::io::Result<()> {
1263
1263
/// use std::fs;
1264
1264
///
1265
- /// let attr = try!( fs::symlink_metadata("/some/file/path.txt")) ;
1265
+ /// let attr = fs::symlink_metadata("/some/file/path.txt")? ;
1266
1266
/// // inspect attr ...
1267
1267
/// # Ok(())
1268
1268
/// # }
@@ -1305,7 +1305,7 @@ pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
1305
1305
/// use std::fs;
1306
1306
///
1307
1307
/// # 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
1309
1309
/// # Ok(())
1310
1310
/// # }
1311
1311
/// ```
@@ -1349,7 +1349,7 @@ pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()>
1349
1349
/// use std::fs;
1350
1350
///
1351
1351
/// # 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
1353
1353
/// # Ok(()) }
1354
1354
/// ```
1355
1355
#[ 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> {
1382
1382
/// use std::fs;
1383
1383
///
1384
1384
/// # 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
1386
1386
/// # Ok(())
1387
1387
/// # }
1388
1388
/// ```
@@ -1405,7 +1405,7 @@ pub fn hard_link<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<(
1405
1405
/// use std::fs;
1406
1406
///
1407
1407
/// # fn foo() -> std::io::Result<()> {
1408
- /// try!( fs::soft_link("a.txt", "b.txt")) ;
1408
+ /// fs::soft_link("a.txt", "b.txt")? ;
1409
1409
/// # Ok(())
1410
1410
/// # }
1411
1411
/// ```
@@ -1441,7 +1441,7 @@ pub fn soft_link<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<(
1441
1441
/// use std::fs;
1442
1442
///
1443
1443
/// # fn foo() -> std::io::Result<()> {
1444
- /// let path = try!( fs::read_link("a.txt")) ;
1444
+ /// let path = fs::read_link("a.txt")? ;
1445
1445
/// # Ok(())
1446
1446
/// # }
1447
1447
/// ```
@@ -1474,7 +1474,7 @@ pub fn read_link<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
1474
1474
/// use std::fs;
1475
1475
///
1476
1476
/// # fn foo() -> std::io::Result<()> {
1477
- /// let path = try!( fs::canonicalize("../a/../foo.txt")) ;
1477
+ /// let path = fs::canonicalize("../a/../foo.txt")? ;
1478
1478
/// # Ok(())
1479
1479
/// # }
1480
1480
/// ```
@@ -1506,7 +1506,7 @@ pub fn canonicalize<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
1506
1506
/// use std::fs;
1507
1507
///
1508
1508
/// # fn foo() -> std::io::Result<()> {
1509
- /// try!( fs::create_dir("/some/dir")) ;
1509
+ /// fs::create_dir("/some/dir")? ;
1510
1510
/// # Ok(())
1511
1511
/// # }
1512
1512
/// ```
@@ -1541,7 +1541,7 @@ pub fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
1541
1541
/// use std::fs;
1542
1542
///
1543
1543
/// # fn foo() -> std::io::Result<()> {
1544
- /// try!( fs::create_dir_all("/some/dir")) ;
1544
+ /// fs::create_dir_all("/some/dir")? ;
1545
1545
/// # Ok(())
1546
1546
/// # }
1547
1547
/// ```
@@ -1573,7 +1573,7 @@ pub fn create_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
1573
1573
/// use std::fs;
1574
1574
///
1575
1575
/// # fn foo() -> std::io::Result<()> {
1576
- /// try!( fs::remove_dir("/some/dir")) ;
1576
+ /// fs::remove_dir("/some/dir")? ;
1577
1577
/// # Ok(())
1578
1578
/// # }
1579
1579
/// ```
@@ -1606,7 +1606,7 @@ pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
1606
1606
/// use std::fs;
1607
1607
///
1608
1608
/// # fn foo() -> std::io::Result<()> {
1609
- /// try!( fs::remove_dir_all("/some/dir")) ;
1609
+ /// fs::remove_dir_all("/some/dir")? ;
1610
1610
/// # Ok(())
1611
1611
/// # }
1612
1612
/// ```
@@ -1649,11 +1649,11 @@ pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
1649
1649
/// // one possible implementation of walking a directory only visiting files
1650
1650
/// fn visit_dirs(dir: &Path, cb: &Fn(&DirEntry)) -> io::Result<()> {
1651
1651
/// 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? ;
1654
1654
/// let path = entry.path();
1655
1655
/// if path.is_dir() {
1656
- /// try!( visit_dirs(&path, cb)) ;
1656
+ /// visit_dirs(&path, cb)? ;
1657
1657
/// } else {
1658
1658
/// cb(&entry);
1659
1659
/// }
@@ -1690,9 +1690,9 @@ pub fn read_dir<P: AsRef<Path>>(path: P) -> io::Result<ReadDir> {
1690
1690
/// # fn foo() -> std::io::Result<()> {
1691
1691
/// use std::fs;
1692
1692
///
1693
- /// let mut perms = try!( fs::metadata("foo.txt")) .permissions();
1693
+ /// let mut perms = fs::metadata("foo.txt")? .permissions();
1694
1694
/// perms.set_readonly(true);
1695
- /// try!( fs::set_permissions("foo.txt", perms)) ;
1695
+ /// fs::set_permissions("foo.txt", perms)? ;
1696
1696
/// # Ok(())
1697
1697
/// # }
1698
1698
/// ```
0 commit comments