@@ -124,7 +124,7 @@ impl File {
124
124
/// This function will return an error if `path` does not already exist.
125
125
/// Other errors may also be returned according to `OpenOptions::open`.
126
126
#[stable(feature = "rust1", since = "1.0.0")]
127
- pub fn open<P: AsPath + ?Sized >(path: & P) -> io::Result<File> {
127
+ pub fn open<P: AsPath>(path: P) -> io::Result<File> {
128
128
OpenOptions::new().read(true).open(path)
129
129
}
130
130
@@ -135,7 +135,7 @@ impl File {
135
135
///
136
136
/// See the `OpenOptions::open` function for more details.
137
137
#[stable(feature = "rust1", since = "1.0.0")]
138
- pub fn create<P: AsPath + ?Sized >(path: & P) -> io::Result<File> {
138
+ pub fn create<P: AsPath>(path: P) -> io::Result<File> {
139
139
OpenOptions::new().write(true).create(true).truncate(true).open(path)
140
140
}
141
141
@@ -297,7 +297,7 @@ impl OpenOptions {
297
297
/// permissions for
298
298
/// * Filesystem-level errors (full disk, etc)
299
299
#[stable(feature = "rust1", since = "1.0.0")]
300
- pub fn open<P: AsPath + ?Sized >(&self, path: & P) -> io::Result<File> {
300
+ pub fn open<P: AsPath>(&self, path: P) -> io::Result<File> {
301
301
let path = path.as_path();
302
302
let inner = try!(fs_imp::File::open(path, &self.0));
303
303
Ok(File { path: path.to_path_buf(), inner: inner })
@@ -410,7 +410,7 @@ impl DirEntry {
410
410
/// user lacks permissions to remove the file, or if some other filesystem-level
411
411
/// error occurs.
412
412
#[stable(feature = "rust1", since = "1.0.0")]
413
- pub fn remove_file<P: AsPath + ?Sized >(path: & P) -> io::Result<()> {
413
+ pub fn remove_file<P: AsPath>(path: P) -> io::Result<()> {
414
414
fs_imp::unlink(path.as_path())
415
415
}
416
416
@@ -438,7 +438,7 @@ pub fn remove_file<P: AsPath + ?Sized>(path: &P) -> io::Result<()> {
438
438
/// permissions to perform a `metadata` call on the given `path` or if there
439
439
/// is no entry in the filesystem at the provided path.
440
440
#[stable(feature = "rust1", since = "1.0.0")]
441
- pub fn metadata<P: AsPath + ?Sized >(path: & P) -> io::Result<Metadata> {
441
+ pub fn metadata<P: AsPath>(path: P) -> io::Result<Metadata> {
442
442
fs_imp::stat(path.as_path()).map(Metadata)
443
443
}
444
444
@@ -459,8 +459,7 @@ pub fn metadata<P: AsPath + ?Sized>(path: &P) -> io::Result<Metadata> {
459
459
/// reside on separate filesystems, or if some other intermittent I/O error
460
460
/// occurs.
461
461
#[stable(feature = "rust1", since = "1.0.0")]
462
- pub fn rename<P: AsPath + ?Sized, Q: AsPath + ?Sized>(from: &P, to: &Q)
463
- -> io::Result<()> {
462
+ pub fn rename<P: AsPath, Q: AsPath>(from: P, to: Q) -> io::Result<()> {
464
463
fs_imp::rename(from.as_path(), to.as_path())
465
464
}
466
465
@@ -490,9 +489,9 @@ pub fn rename<P: AsPath + ?Sized, Q: AsPath + ?Sized>(from: &P, to: &Q)
490
489
/// * The current process does not have the permission rights to access
491
490
/// `from` or write `to`
492
491
#[stable(feature = "rust1", since = "1.0.0")]
493
- pub fn copy<P: AsPath + ?Sized, Q: AsPath + ?Sized>(from: &P, to: &Q)
494
- -> io::Result<u64> {
492
+ pub fn copy<P: AsPath, Q: AsPath>(from: P, to: Q) -> io::Result<u64> {
495
493
let from = from.as_path();
494
+ let to = to.as_path();
496
495
if !from.is_file() {
497
496
return Err(Error::new(ErrorKind::MismatchedFileTypeForOperation,
498
497
"the source path is not an existing file",
@@ -513,17 +512,15 @@ pub fn copy<P: AsPath + ?Sized, Q: AsPath + ?Sized>(from: &P, to: &Q)
513
512
/// The `dst` path will be a link pointing to the `src` path. Note that systems
514
513
/// often require these two paths to both be located on the same filesystem.
515
514
#[stable(feature = "rust1", since = "1.0.0")]
516
- pub fn hard_link<P: AsPath + ?Sized, Q: AsPath + ?Sized>(src: &P, dst: &Q)
517
- -> io::Result<()> {
515
+ pub fn hard_link<P: AsPath, Q: AsPath>(src: P, dst: Q) -> io::Result<()> {
518
516
fs_imp::link(src.as_path(), dst.as_path())
519
517
}
520
518
521
519
/// Creates a new soft link on the filesystem.
522
520
///
523
521
/// The `dst` path will be a soft link pointing to the `src` path.
524
522
#[stable(feature = "rust1", since = "1.0.0")]
525
- pub fn soft_link<P: AsPath + ?Sized, Q: AsPath + ?Sized>(src: &P, dst: &Q)
526
- -> io::Result<()> {
523
+ pub fn soft_link<P: AsPath, Q: AsPath>(src: P, dst: Q) -> io::Result<()> {
527
524
fs_imp::symlink(src.as_path(), dst.as_path())
528
525
}
529
526
@@ -535,7 +532,7 @@ pub fn soft_link<P: AsPath + ?Sized, Q: AsPath + ?Sized>(src: &P, dst: &Q)
535
532
/// reading a file that does not exist or reading a file that is not a soft
536
533
/// link.
537
534
#[stable(feature = "rust1", since = "1.0.0")]
538
- pub fn read_link<P: AsPath + ?Sized >(path: & P) -> io::Result<PathBuf> {
535
+ pub fn read_link<P: AsPath>(path: P) -> io::Result<PathBuf> {
539
536
fs_imp::readlink(path.as_path())
540
537
}
541
538
@@ -554,7 +551,7 @@ pub fn read_link<P: AsPath + ?Sized>(path: &P) -> io::Result<PathBuf> {
554
551
/// This function will return an error if the user lacks permissions to make a
555
552
/// new directory at the provided `path`, or if the directory already exists.
556
553
#[stable(feature = "rust1", since = "1.0.0")]
557
- pub fn create_dir<P: AsPath + ?Sized >(path: & P) -> io::Result<()> {
554
+ pub fn create_dir<P: AsPath>(path: P) -> io::Result<()> {
558
555
fs_imp::mkdir(path.as_path())
559
556
}
560
557
@@ -568,7 +565,7 @@ pub fn create_dir<P: AsPath + ?Sized>(path: &P) -> io::Result<()> {
568
565
/// error conditions for when a directory is being created (after it is
569
566
/// determined to not exist) are outlined by `fs::create_dir`.
570
567
#[stable(feature = "rust1", since = "1.0.0")]
571
- pub fn create_dir_all<P: AsPath + ?Sized >(path: & P) -> io::Result<()> {
568
+ pub fn create_dir_all<P: AsPath>(path: P) -> io::Result<()> {
572
569
let path = path.as_path();
573
570
if path.is_dir() { return Ok(()) }
574
571
if let Some(p) = path.parent() { try!(create_dir_all(p)) }
@@ -590,7 +587,7 @@ pub fn create_dir_all<P: AsPath + ?Sized>(path: &P) -> io::Result<()> {
590
587
/// This function will return an error if the user lacks permissions to remove
591
588
/// the directory at the provided `path`, or if the directory isn't empty.
592
589
#[stable(feature = "rust1", since = "1.0.0")]
593
- pub fn remove_dir<P: AsPath + ?Sized >(path: & P) -> io::Result<()> {
590
+ pub fn remove_dir<P: AsPath>(path: P) -> io::Result<()> {
594
591
fs_imp::rmdir(path.as_path())
595
592
}
596
593
@@ -604,7 +601,7 @@ pub fn remove_dir<P: AsPath + ?Sized>(path: &P) -> io::Result<()> {
604
601
///
605
602
/// See `file::remove_file` and `fs::remove_dir`
606
603
#[stable(feature = "rust1", since = "1.0.0")]
607
- pub fn remove_dir_all<P: AsPath + ?Sized >(path: & P) -> io::Result<()> {
604
+ pub fn remove_dir_all<P: AsPath>(path: P) -> io::Result<()> {
608
605
let path = path.as_path();
609
606
for child in try!(read_dir(path)) {
610
607
let child = try!(child).path();
@@ -657,7 +654,7 @@ pub fn remove_dir_all<P: AsPath + ?Sized>(path: &P) -> io::Result<()> {
657
654
/// the process lacks permissions to view the contents or if the `path` points
658
655
/// at a non-directory file
659
656
#[stable(feature = "rust1", since = "1.0.0")]
660
- pub fn read_dir<P: AsPath + ?Sized >(path: & P) -> io::Result<ReadDir> {
657
+ pub fn read_dir<P: AsPath>(path: P) -> io::Result<ReadDir> {
661
658
fs_imp::readdir(path.as_path()).map(ReadDir)
662
659
}
663
660
@@ -673,7 +670,7 @@ pub fn read_dir<P: AsPath + ?Sized>(path: &P) -> io::Result<ReadDir> {
673
670
reason = "the precise semantics and defaults for a recursive walk \
674
671
may change and this may end up accounting for files such \
675
672
as symlinks differently")]
676
- pub fn walk_dir<P: AsPath + ?Sized >(path: & P) -> io::Result<WalkDir> {
673
+ pub fn walk_dir<P: AsPath>(path: P) -> io::Result<WalkDir> {
677
674
let start = try!(read_dir(path));
678
675
Ok(WalkDir { cur: Some(start), stack: Vec::new() })
679
676
}
@@ -759,8 +756,8 @@ impl PathExt for Path {
759
756
reason = "the argument type of u64 is not quite appropriate for \
760
757
this function and may change if the standard library \
761
758
gains a type to represent a moment in time")]
762
- pub fn set_file_times<P: AsPath + ?Sized >(path: & P, accessed: u64,
763
- modified: u64) -> io::Result<()> {
759
+ pub fn set_file_times<P: AsPath>(path: P, accessed: u64,
760
+ modified: u64) -> io::Result<()> {
764
761
fs_imp::utimes(path.as_path(), accessed, modified)
765
762
}
766
763
@@ -788,8 +785,7 @@ pub fn set_file_times<P: AsPath + ?Sized>(path: &P, accessed: u64,
788
785
reason = "a more granual ability to set specific permissions may \
789
786
be exposed on the Permissions structure itself and this \
790
787
method may not always exist")]
791
- pub fn set_permissions<P: AsPath + ?Sized>(path: &P, perm: Permissions)
792
- -> io::Result<()> {
788
+ pub fn set_permissions<P: AsPath>(path: P, perm: Permissions) -> io::Result<()> {
793
789
fs_imp::set_perm(path.as_path(), perm.0)
794
790
}
795
791
0 commit comments