path2: Update for changes from master

This commit is contained in:
Kevin Ballard 2013-09-30 17:13:13 -07:00
parent 6f5b809775
commit 3d80a2f1f1
2 changed files with 13 additions and 13 deletions

View file

@ -13,7 +13,7 @@
use container::Container;
use c_str::CString;
use clone::Clone;
use iterator::Iterator;
use iter::Iterator;
use option::{Option, None, Some};
use str;
use str::StrSlice;
@ -102,7 +102,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// If the path is not representable in utf-8, this returns None.
#[inline]
fn as_str<'a>(&'a self) -> Option<&'a str> {
str::from_bytes_slice_opt(self.as_vec())
str::from_utf8_slice_opt(self.as_vec())
}
/// Returns the path as a byte vector
@ -115,7 +115,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// See `dirname` for details.
#[inline]
fn dirname_str<'a>(&'a self) -> Option<&'a str> {
str::from_bytes_slice_opt(self.dirname())
str::from_utf8_slice_opt(self.dirname())
}
/// Returns the file component of `self`, as a byte vector.
/// If `self` represents the root of the file hierarchy, returns the empty vector.
@ -125,7 +125,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// See `filename` for details.
#[inline]
fn filename_str<'a>(&'a self) -> Option<&'a str> {
str::from_bytes_slice_opt(self.filename())
str::from_utf8_slice_opt(self.filename())
}
/// Returns the stem of the filename of `self`, as a byte vector.
/// The stem is the portion of the filename just before the last '.'.
@ -143,7 +143,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// See `filestem` for details.
#[inline]
fn filestem_str<'a>(&'a self) -> Option<&'a str> {
str::from_bytes_slice_opt(self.filestem())
str::from_utf8_slice_opt(self.filestem())
}
/// Returns the extension of the filename of `self`, as an optional byte vector.
/// The extension is the portion of the filename just after the last '.'.
@ -162,7 +162,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// See `extension` for details.
#[inline]
fn extension_str<'a>(&'a self) -> Option<&'a str> {
self.extension().chain(|v| str::from_bytes_slice_opt(v))
self.extension().and_then(|v| str::from_utf8_slice_opt(v))
}
/// Replaces the directory portion of the path with the given byte vector.
@ -447,7 +447,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// See `pop_opt` for details.
#[inline]
fn pop_opt_str(&mut self) -> Option<~str> {
self.pop_opt().chain(|v| str::from_bytes_owned_opt(v))
self.pop_opt().and_then(|v| str::from_utf8_owned_opt(v))
}
/// Returns a new Path constructed by joining `self` with the given path (as a byte vector).

View file

@ -15,7 +15,7 @@ use c_str::{CString, ToCStr};
use clone::Clone;
use cmp::Eq;
use from_str::FromStr;
use iterator::{AdditiveIterator, Extendable, Iterator};
use iter::{AdditiveIterator, Extendable, Iterator};
use option::{Option, None, Some};
use str;
use str::Str;
@ -303,7 +303,7 @@ impl Path {
/// Converts the Path into an owned string, if possible
pub fn into_str(self) -> Option<~str> {
str::from_bytes_owned_opt(self.repr)
str::from_utf8_owned_opt(self.repr)
}
/// Returns a normalized byte vector representation of a path, by removing all empty
@ -406,7 +406,7 @@ static dot_dot_static: &'static [u8] = &'static ['.' as u8, '.' as u8];
mod tests {
use super::*;
use option::{Some, None};
use iterator::Iterator;
use iter::Iterator;
use str;
use vec::Vector;
@ -589,7 +589,7 @@ mod tests {
(s: $path:expr, $op:ident, $exp:expr, opt) => (
{
let path = Path::from_str($path);
let left = path.$op().map(|&x| str::from_bytes_slice(x));
let left = path.$op().map(|&x| str::from_utf8_slice(x));
assert_eq!(left, $exp);
}
);
@ -1006,7 +1006,7 @@ mod tests {
(s: $path:expr, $exp:expr) => (
{
let path = $path;
let left = path.chain_ref(|p| p.as_str());
let left = path.and_then_ref(|p| p.as_str());
assert_eq!(left, $exp);
}
);
@ -1083,7 +1083,7 @@ mod tests {
let path = Path::from_str($path);
let other = Path::from_str($other);
let res = path.path_relative_from(&other);
assert_eq!(res.chain_ref(|x| x.as_str()), $exp);
assert_eq!(res.and_then_ref(|x| x.as_str()), $exp);
}
)
)