Skip to content

Commit 3014439

Browse files
committed
Take &P where P: AsPath instead of &Path.
1 parent c4c414d commit 3014439

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "url"
4-
version = "0.2.24"
4+
version = "0.2.25"
55
authors = [ "Simon Sapin <[email protected]>" ]
66

77
description = "URL parser for Rust"

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ extern crate matches;
128128

129129
use std::fmt::{self, Formatter};
130130
use std::hash;
131-
use std::path::{Path, PathBuf};
131+
use std::path::{Path, PathBuf, AsPath};
132132

133133
pub use host::{Host, Ipv6Address};
134134
pub use parser::{ErrorHandler, ParseResult, ParseError};
@@ -479,8 +479,8 @@ impl Url {
479479
///
480480
/// This returns `Err` if the given path is not absolute
481481
/// 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()));
484484
Ok(Url::from_path_common(path))
485485
}
486486

@@ -501,8 +501,8 @@ impl Url {
501501
/// as the base URL is `file:///var/index.html`, which might not be what was intended.
502502
///
503503
/// (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()));
506506
// Add an empty path component (i.e. a trailing slash in serialization)
507507
// so that the entire path is used as a base URL.
508508
path.push("".to_string());

0 commit comments

Comments
 (0)