@@ -128,7 +128,7 @@ extern crate matches;
128
128
129
129
use std:: fmt:: { self , Formatter } ;
130
130
use std:: hash;
131
- use std:: path:: { Path , PathBuf } ;
131
+ use std:: path:: { Path , PathBuf , AsPath } ;
132
132
133
133
pub use host:: { Host , Ipv6Address } ;
134
134
pub use parser:: { ErrorHandler , ParseResult , ParseError } ;
@@ -479,8 +479,8 @@ impl Url {
479
479
///
480
480
/// This returns `Err` if the given path is not absolute
481
481
/// or, with a Windows path, if the prefix is not a disk prefix (e.g. `C:`).
482
- pub fn from_file_path ( path : & Path ) -> Result < Url , ( ) > {
483
- let path = try!( path_to_file_url_path ( path) ) ;
482
+ pub fn from_file_path < P : AsPath + ? Sized > ( path : & P ) -> Result < Url , ( ) > {
483
+ let path = try!( path_to_file_url_path ( path. as_path ( ) ) ) ;
484
484
Ok ( Url :: from_path_common ( path) )
485
485
}
486
486
@@ -501,8 +501,8 @@ impl Url {
501
501
/// as the base URL is `file:///var/index.html`, which might not be what was intended.
502
502
///
503
503
/// (Note that `Path::new` removes any trailing slash.)
504
- pub fn from_directory_path ( path : & Path ) -> Result < Url , ( ) > {
505
- let mut path = try!( path_to_file_url_path ( path) ) ;
504
+ pub fn from_directory_path < P : AsPath + ? Sized > ( path : & P ) -> Result < Url , ( ) > {
505
+ let mut path = try!( path_to_file_url_path ( path. as_path ( ) ) ) ;
506
506
// Add an empty path component (i.e. a trailing slash in serialization)
507
507
// so that the entire path is used as a base URL.
508
508
path. push ( "" . to_string ( ) ) ;
0 commit comments