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