Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ec5cbb4f
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
ec5cbb4f
编写于
6月 05, 2012
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core: Remove swappable. Unused
上级
d3c64167
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
0 addition
and
100 deletion
+0
-100
src/libcore/core.rc
src/libcore/core.rc
+0
-2
src/libcore/swappable.rs
src/libcore/swappable.rs
+0
-98
未找到文件。
src/libcore/core.rc
浏览文件 @
ec5cbb4f
...
...
@@ -43,7 +43,6 @@ export comm, task, future;
export extfmt;
export tuple;
export to_str;
export swappable;
export dvec, dvec_iter;
// NDM seems to be necessary for resolve to work
...
...
@@ -164,7 +163,6 @@ mod option_iter {
}
mod result;
mod to_str;
mod swappable;
mod dvec;
#[path="iter-trait"]
mod dvec_iter {
...
...
src/libcore/swappable.rs
已删除
100644 → 0
浏览文件 @
d3c64167
export
swappable
;
export
unwrap
;
export
methods
;
#[doc
=
"
A value that may be swapped out temporarily while it is being processed
and then replaced. Swappables are most useful when working with unique
values, which often cannot be mutated unless they are stored in the local
stack frame to ensure memory safety.
The type guarantees the invariant that the value is always
\"
swapped in
\"
except during the execution of the `swap()` and `with()` methods.
"
]
type
swappable
<
A
>
=
{
mut
o_t
:
option
<
A
>
};
#[doc
=
"Create a swappable swapped in with a given initial value"
]
fn
swappable
<
A
>
(
+
t
:
A
)
->
swappable
<
A
>
{
{
mut
o_t
:
some
(
t
)}
}
#[doc
=
"Consumes a swappable and returns its contents without copying"
]
fn
unwrap
<
A
>
(
-
s
:
swappable
<
A
>
)
->
A
{
let
{
o_t
:
o_t
}
<-
s
;
option
::
unwrap
(
o_t
)
}
impl
methods
<
A
>
for
swappable
<
A
>
{
#[doc
=
"
Overwrites the contents of the swappable
"
]
fn
set
(
+
a
:
A
)
{
self
.o_t
<-
some
(
a
);
}
#[doc
=
"
Invokes `f()` with the current value but replaces the
current value when complete. Returns the result of `f()`.
Attempts to read or access the receiver while `f()` is executing
will fail dynamically.
"
]
fn
with
<
B
>
(
f
:
fn
(
A
)
->
B
)
->
B
{
let
mut
o_u
=
none
;
self
.swap
{
|
t
|
o_u
<-
some
(
f
(
t
));
t
}
option
::
unwrap
(
o_u
)
}
#[doc
=
"
Invokes `f()` with the current value and then replaces the
current value with the result of `f()`.
Attempts to read or access the receiver while `f()` is executing
will fail dynamically.
"
]
fn
swap
(
f
:
fn
(
-
A
)
->
A
)
{
alt
self
.o_t
{
none
{
fail
"no value present---already swapped?"
;
}
some
(
_
)
{}
}
let
mut
o_t
=
none
;
o_t
<->
self
.o_t
;
self
.o_t
<-
some
(
f
(
option
::
unwrap
(
o_t
)));
}
#[doc
=
"True if there is a value present in this swappable"
]
fn
is_present
()
->
bool
{
alt
self
.o_t
{
none
{
false
}
some
(
_
)
{
true
}
}
}
#[doc
=
"
Removes the value from the swappable. Any further attempts
to use the swapabble without first invoking `set()` will fail.
"
]
fn
take
()
->
A
{
alt
self
.o_t
{
none
{
fail
"swapped out"
;
}
some
(
_
)
{}
}
let
mut
o_t
=
none
;
option
::
unwrap
(
o_t
)
}
}
impl
methods
<
A
:
copy
>
for
swappable
<
A
>
{
#[doc
=
"
Copies out the contents of the swappable
"
]
fn
get
()
->
A
{
self
.o_t
.get
()
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录