path2: Remove Path.into_str()
This commit is contained in:
parent
0c7e8f7a92
commit
40b324f0de
@ -179,9 +179,6 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
|
||||
str::from_utf8_slice_opt(self.as_vec())
|
||||
}
|
||||
|
||||
/// Converts the Path into an owned string, if possible
|
||||
fn into_str(self) -> Option<~str>;
|
||||
|
||||
/// Returns the path as a byte vector
|
||||
fn as_vec<'a>(&'a self) -> &'a [u8];
|
||||
|
||||
|
@ -178,10 +178,6 @@ impl GenericPath for Path {
|
||||
self.repr
|
||||
}
|
||||
|
||||
fn into_str(self) -> Option<~str> {
|
||||
str::from_utf8_owned_opt(self.repr)
|
||||
}
|
||||
|
||||
fn dirname<'a>(&'a self) -> &'a [u8] {
|
||||
match self.sepidx {
|
||||
None if bytes!("..") == self.repr => self.repr.as_slice(),
|
||||
@ -614,12 +610,9 @@ mod tests {
|
||||
assert_eq!(Path::new(b!("foo/bar")).into_vec(), b!("foo/bar").to_owned());
|
||||
assert_eq!(Path::new(b!("/foo/../../bar")).into_vec(),
|
||||
b!("/bar").to_owned());
|
||||
assert_eq!(Path::new("foo/bar").into_str(), Some(~"foo/bar"));
|
||||
assert_eq!(Path::new("/foo/../../bar").into_str(), Some(~"/bar"));
|
||||
|
||||
let p = Path::new(b!("foo/bar", 0x80));
|
||||
assert_eq!(p.as_str(), None);
|
||||
assert_eq!(Path::new(b!("foo", 0xff, "/bar")).into_str(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -327,13 +327,6 @@ impl GenericPath for Path {
|
||||
Some(self.repr.as_slice())
|
||||
}
|
||||
|
||||
/// See `GenericPath::into_str` for info.
|
||||
/// Always returns a `Some` value.
|
||||
#[inline]
|
||||
fn into_str(self) -> Option<~str> {
|
||||
Some(self.repr)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn as_vec<'a>(&'a self) -> &'a [u8] {
|
||||
self.repr.as_bytes()
|
||||
@ -1260,8 +1253,6 @@ mod tests {
|
||||
assert_eq!(Path::new(b!("foo\\bar")).into_vec(), b!("foo\\bar").to_owned());
|
||||
assert_eq!(Path::new(b!("\\foo\\..\\..\\bar")).into_vec(),
|
||||
b!("\\bar").to_owned());
|
||||
assert_eq!(Path::new("foo\\bar").into_str(), Some(~"foo\\bar"));
|
||||
assert_eq!(Path::new("\\foo\\..\\..\\bar").into_str(), Some(~"\\bar"));
|
||||
|
||||
t!(s: Path::new("\\\\a"), "\\a");
|
||||
t!(s: Path::new("\\\\a\\"), "\\a");
|
||||
|
Loading…
x
Reference in New Issue
Block a user