提交 3d80a2f1 编写于 作者: K Kevin Ballard

path2: Update for changes from master

上级 6f5b8097
......@@ -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 @@ fn from_c_str(path: CString) -> Self {
/// 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 @@ fn as_str<'a>(&'a self) -> Option<&'a str> {
/// 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 @@ fn dirname_str<'a>(&'a self) -> Option<&'a str> {
/// 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 @@ fn filestem<'a>(&'a self) -> &'a [u8] {
/// 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 @@ fn extension<'a>(&'a self) -> Option<&'a [u8]> {
/// 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 @@ fn push_path(&mut self, path: &Self) {
/// 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).
......
......@@ -15,7 +15,7 @@
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 @@ pub fn into_vec(self) -> ~[u8] {
/// 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 @@ fn contains_nul(v: &[u8]) -> bool {
mod tests {
use super::*;
use option::{Some, None};
use iterator::Iterator;
use iter::Iterator;
use str;
use vec::Vector;
......@@ -589,7 +589,7 @@ fn test_components() {
(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 @@ fn test_dir_file_path() {
(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 @@ fn test_path_relative_from() {
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);
}
)
)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册