Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
1133a149
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,发现更多精彩内容 >>
提交
1133a149
编写于
4月 22, 2018
作者:
G
George Burton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement From for more types on Cow
上级
ff48277a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
71 addition
and
0 deletion
+71
-0
src/liballoc/string.rs
src/liballoc/string.rs
+8
-0
src/liballoc/vec.rs
src/liballoc/vec.rs
+7
-0
src/libstd/ffi/c_str.rs
src/libstd/ffi/c_str.rs
+24
-0
src/libstd/ffi/os_str.rs
src/libstd/ffi/os_str.rs
+24
-0
src/libstd/path.rs
src/libstd/path.rs
+8
-0
未找到文件。
src/liballoc/string.rs
浏览文件 @
1133a149
...
...
@@ -2239,6 +2239,14 @@ fn from(s: String) -> Cow<'a, str> {
}
}
#[stable(feature
=
"cow_from_string_ref"
,
since
=
"1.28.0"
)]
impl
<
'a
>
From
<&
'a
String
>
for
Cow
<
'a
,
str
>
{
#[inline]
fn
from
(
s
:
&
'a
String
)
->
Cow
<
'a
,
str
>
{
Cow
::
Borrowed
(
s
.as_str
())
}
}
#[stable(feature
=
"cow_str_from_iter"
,
since
=
"1.12.0"
)]
impl
<
'a
>
FromIterator
<
char
>
for
Cow
<
'a
,
str
>
{
fn
from_iter
<
I
:
IntoIterator
<
Item
=
char
>>
(
it
:
I
)
->
Cow
<
'a
,
str
>
{
...
...
src/liballoc/vec.rs
浏览文件 @
1133a149
...
...
@@ -2285,6 +2285,13 @@ fn from(v: Vec<T>) -> Cow<'a, [T]> {
}
}
#[stable(feature
=
"cow_from_vec_ref"
,
since
=
"1.28.0"
)]
impl
<
'a
,
T
:
Clone
>
From
<&
'a
Vec
<
T
>>
for
Cow
<
'a
,
[
T
]
>
{
fn
from
(
v
:
&
'a
Vec
<
T
>
)
->
Cow
<
'a
,
[
T
]
>
{
Cow
::
Borrowed
(
v
.as_slice
())
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
'a
,
T
>
FromIterator
<
T
>
for
Cow
<
'a
,
[
T
]
>
where
T
:
Clone
{
fn
from_iter
<
I
:
IntoIterator
<
Item
=
T
>>
(
it
:
I
)
->
Cow
<
'a
,
[
T
]
>
{
...
...
src/libstd/ffi/c_str.rs
浏览文件 @
1133a149
...
...
@@ -706,6 +706,30 @@ fn from(s: CString) -> Box<CStr> {
}
}
#[stable(feature
=
"cow_from_cstr"
,
since
=
"1.28.0"
)]
impl
<
'a
>
From
<
CString
>
for
Cow
<
'a
,
CStr
>
{
#[inline]
fn
from
(
s
:
CString
)
->
Cow
<
'a
,
CStr
>
{
Cow
::
Owned
(
s
)
}
}
#[stable(feature
=
"cow_from_cstr"
,
since
=
"1.28.0"
)]
impl
<
'a
>
From
<&
'a
CStr
>
for
Cow
<
'a
,
CStr
>
{
#[inline]
fn
from
(
s
:
&
'a
CStr
)
->
Cow
<
'a
,
CStr
>
{
Cow
::
Borrowed
(
s
)
}
}
#[stable(feature
=
"cow_from_cstr"
,
since
=
"1.28.0"
)]
impl
<
'a
>
From
<&
'a
CString
>
for
Cow
<
'a
,
CStr
>
{
#[inline]
fn
from
(
s
:
&
'a
CString
)
->
Cow
<
'a
,
CStr
>
{
Cow
::
Borrowed
(
s
.as_c_str
())
}
}
#[stable(feature
=
"shared_from_slice2"
,
since
=
"1.24.0"
)]
impl
From
<
CString
>
for
Arc
<
CStr
>
{
#[inline]
...
...
src/libstd/ffi/os_str.rs
浏览文件 @
1133a149
...
...
@@ -664,6 +664,30 @@ fn from(s: &OsStr) -> Rc<OsStr> {
}
}
#[stable(feature
=
"cow_from_osstr"
,
since
=
"1.28.0"
)]
impl
<
'a
>
From
<
OsString
>
for
Cow
<
'a
,
OsStr
>
{
#[inline]
fn
from
(
s
:
OsString
)
->
Cow
<
'a
,
OsStr
>
{
Cow
::
Owned
(
s
)
}
}
#[stable(feature
=
"cow_from_osstr"
,
since
=
"1.28.0"
)]
impl
<
'a
>
From
<&
'a
OsStr
>
for
Cow
<
'a
,
OsStr
>
{
#[inline]
fn
from
(
s
:
&
'a
OsStr
)
->
Cow
<
'a
,
OsStr
>
{
Cow
::
Borrowed
(
s
)
}
}
#[stable(feature
=
"cow_from_osstr"
,
since
=
"1.28.0"
)]
impl
<
'a
>
From
<&
'a
OsString
>
for
Cow
<
'a
,
OsStr
>
{
#[inline]
fn
from
(
s
:
&
'a
OsString
)
->
Cow
<
'a
,
OsStr
>
{
Cow
::
Borrowed
(
s
.as_os_str
())
}
}
#[stable(feature
=
"box_default_extra"
,
since
=
"1.17.0"
)]
impl
Default
for
Box
<
OsStr
>
{
fn
default
()
->
Box
<
OsStr
>
{
...
...
src/libstd/path.rs
浏览文件 @
1133a149
...
...
@@ -1532,6 +1532,14 @@ fn from(s: PathBuf) -> Cow<'a, Path> {
}
}
#[stable(feature
=
"cow_from_pathbuf_ref"
,
since
=
"1.28.0"
)]
impl
<
'a
>
From
<&
'a
PathBuf
>
for
Cow
<
'a
,
Path
>
{
#[inline]
fn
from
(
p
:
&
'a
PathBuf
)
->
Cow
<
'a
,
Path
>
{
Cow
::
Borrowed
(
p
.as_path
())
}
}
#[stable(feature
=
"shared_from_slice2"
,
since
=
"1.24.0"
)]
impl
From
<
PathBuf
>
for
Arc
<
Path
>
{
#[inline]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录