Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
3d80a2f1
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3d80a2f1
编写于
9月 30, 2013
作者:
K
Kevin Ballard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
path2: Update for changes from master
上级
6f5b8097
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
13 deletion
+13
-13
src/libstd/path2/mod.rs
src/libstd/path2/mod.rs
+7
-7
src/libstd/path2/posix.rs
src/libstd/path2/posix.rs
+6
-6
未找到文件。
src/libstd/path2/mod.rs
浏览文件 @
3d80a2f1
...
...
@@ -13,7 +13,7 @@
use
container
::
Container
;
use
c_str
::
CString
;
use
clone
::
Clone
;
use
iter
ator
::
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).
...
...
src/libstd/path2/posix.rs
浏览文件 @
3d80a2f1
...
...
@@ -15,7 +15,7 @@
use
clone
::
Clone
;
use
cmp
::
Eq
;
use
from_str
::
FromStr
;
use
iter
ator
::{
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
iter
ator
::
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
.
chai
n_ref
(|
p
|
p
.as_str
());
let
left
=
path
.
and_the
n_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
.
chai
n_ref
(|
x
|
x
.as_str
()),
$exp
);
assert_eq!
(
res
.
and_the
n_ref
(|
x
|
x
.as_str
()),
$exp
);
}
)
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录