Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
68c852ad
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,发现更多精彩内容 >>
提交
68c852ad
编写于
11月 17, 2012
作者:
J
Jesse Jones
提交者:
Brian Anderson
11月 18, 2012
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Made Map.contains_key, contains_key_ref, and get pure.
上级
1a1e99c2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
17 addition
and
17 deletion
+17
-17
src/libcore/mutable.rs
src/libcore/mutable.rs
+1
-1
src/libstd/map.rs
src/libstd/map.rs
+9
-9
src/libstd/smallintmap.rs
src/libstd/smallintmap.rs
+4
-4
src/test/run-pass/class-impl-very-parameterized-trait.rs
src/test/run-pass/class-impl-very-parameterized-trait.rs
+3
-3
未找到文件。
src/libcore/mutable.rs
浏览文件 @
68c852ad
...
...
@@ -48,7 +48,7 @@ fn borrow_mut<R>(op: &fn(t: &mut T) -> R) -> R {
}
}
fn
borrow_const
<
R
>
(
op
:
&
fn
(
t
:
&
const
T
)
->
R
)
->
R
{
pure
fn
borrow_const
<
R
>
(
op
:
&
fn
(
t
:
&
const
T
)
->
R
)
->
R
{
op
(
&
const
self
.value
)
}
...
...
src/libstd/map.rs
浏览文件 @
68c852ad
...
...
@@ -30,17 +30,17 @@ pub trait Map<K:Eq IterBytes Hash Copy, V: Copy> {
fn
insert
(
v
:
K
,
v
:
V
)
->
bool
;
/// Returns true if the map contains a value for the specified key
fn
contains_key
(
key
:
K
)
->
bool
;
pure
fn
contains_key
(
key
:
K
)
->
bool
;
/// Returns true if the map contains a value for the specified
/// key, taking the key by reference.
fn
contains_key_ref
(
key
:
&
K
)
->
bool
;
pure
fn
contains_key_ref
(
key
:
&
K
)
->
bool
;
/**
* Get the value for the specified key. Fails if the key does not exist in
* the map.
*/
fn
get
(
key
:
K
)
->
V
;
pure
fn
get
(
key
:
K
)
->
V
;
/**
* Get the value for the specified key. If the key does not exist in
...
...
@@ -200,11 +200,11 @@ fn rehash() {
impl
<
K
:
Eq
IterBytes
Hash
Copy
,
V
:
Copy
>
T
<
K
,
V
>
:
Map
<
K
,
V
>
{
pure
fn
size
()
->
uint
{
self
.count
}
fn
contains_key
(
k
:
K
)
->
bool
{
pure
fn
contains_key
(
k
:
K
)
->
bool
{
self
.contains_key_ref
(
&
k
)
}
fn
contains_key_ref
(
k
:
&
K
)
->
bool
{
pure
fn
contains_key_ref
(
k
:
&
K
)
->
bool
{
let
hash
=
k
.hash_keyed
(
0
,
0
)
as
uint
;
match
self
.search_tbl
(
k
,
hash
)
{
NotFound
=>
false
,
...
...
@@ -264,7 +264,7 @@ fn insert(k: K, v: V) -> bool {
}
}
fn
get
(
k
:
K
)
->
V
{
pure
fn
get
(
k
:
K
)
->
V
{
let
opt_v
=
self
.find
(
k
);
if
opt_v
.is_none
()
{
fail
fmt!
(
"Key not found in table: %?"
,
k
);
...
...
@@ -421,19 +421,19 @@ fn insert(key: K, value: V) -> bool {
}
}
fn
contains_key
(
key
:
K
)
->
bool
{
pure
fn
contains_key
(
key
:
K
)
->
bool
{
do
self
.borrow_const
|
p
|
{
p
.contains_key
(
&
key
)
}
}
fn
contains_key_ref
(
key
:
&
K
)
->
bool
{
pure
fn
contains_key_ref
(
key
:
&
K
)
->
bool
{
do
self
.borrow_const
|
p
|
{
p
.contains_key
(
key
)
}
}
fn
get
(
key
:
K
)
->
V
{
pure
fn
get
(
key
:
K
)
->
V
{
do
self
.borrow_const
|
p
|
{
p
.get
(
&
key
)
}
...
...
src/libstd/smallintmap.rs
浏览文件 @
68c852ad
...
...
@@ -60,7 +60,7 @@ pub fn insert<T: Copy>(self: SmallIntMap<T>, key: uint, val: T) {
}
/// Returns true if the map contains a value for the specified key
pub
fn
contains_key
<
T
:
Copy
>
(
self
:
SmallIntMap
<
T
>
,
key
:
uint
)
->
bool
{
pub
pure
fn
contains_key
<
T
:
Copy
>
(
self
:
SmallIntMap
<
T
>
,
key
:
uint
)
->
bool
{
return
!
find
(
self
,
key
)
.is_none
();
}
...
...
@@ -93,13 +93,13 @@ fn remove(key: uint) -> bool {
fn
clear
()
{
self
.v
.set
(
~
[]);
}
fn
contains_key
(
key
:
uint
)
->
bool
{
pure
fn
contains_key
(
key
:
uint
)
->
bool
{
contains_key
(
self
,
key
)
}
fn
contains_key_ref
(
key
:
&
uint
)
->
bool
{
pure
fn
contains_key_ref
(
key
:
&
uint
)
->
bool
{
contains_key
(
self
,
*
key
)
}
fn
get
(
key
:
uint
)
->
V
{
get
(
self
,
key
)
}
pure
fn
get
(
key
:
uint
)
->
V
{
get
(
self
,
key
)
}
pure
fn
find
(
key
:
uint
)
->
Option
<
V
>
{
find
(
self
,
key
)
}
fn
rehash
()
{
fail
}
...
...
src/test/run-pass/class-impl-very-parameterized-trait.rs
浏览文件 @
68c852ad
...
...
@@ -47,10 +47,10 @@ fn insert(+k: int, +_v: T) -> bool {
self
.meows
+=
k
;
true
}
fn
contains_key
(
+
k
:
int
)
->
bool
{
k
<=
self
.meows
}
fn
contains_key_ref
(
k
:
&
int
)
->
bool
{
self
.contains_key
(
*
k
)
}
pure
fn
contains_key
(
+
k
:
int
)
->
bool
{
k
<=
self
.meows
}
pure
fn
contains_key_ref
(
k
:
&
int
)
->
bool
{
self
.contains_key
(
*
k
)
}
fn
get
(
+
k
:
int
)
->
T
{
match
self
.find
(
k
)
{
pure
fn
get
(
+
k
:
int
)
->
T
{
match
self
.find
(
k
)
{
Some
(
v
)
=>
{
v
}
None
=>
{
fail
~
"epic fail"
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录