Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
3e7a04cb
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,发现更多精彩内容 >>
提交
3e7a04cb
编写于
2月 18, 2015
作者:
A
Alex Crichton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Round 2 test fixes and conflicts
上级
231eeaa3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
131 addition
and
27 deletion
+131
-27
src/libcore/hash/mod.rs
src/libcore/hash/mod.rs
+115
-11
src/libstd/collections/hash/map_stage0.rs
src/libstd/collections/hash/map_stage0.rs
+13
-13
src/libstd/collections/hash/set_stage0.rs
src/libstd/collections/hash/set_stage0.rs
+3
-3
未找到文件。
src/libcore/hash/mod.rs
浏览文件 @
3e7a04cb
...
...
@@ -231,7 +231,6 @@ pub fn hash<T: Hash, H: Hasher + Default>(value: &T) -> u64 {
mod
impls
{
use
prelude
::
*
;
use
borrow
::{
Cow
,
ToOwned
};
use
mem
;
use
num
::
Int
;
use
super
::
*
;
...
...
@@ -364,22 +363,12 @@ fn hash(&self, state: &mut S) {
(
*
self
as
uint
)
.hash
(
state
);
}
}
impl
<
'a
,
T
,
B
:
?
Sized
,
S
:
Hasher
>
Hash
<
S
>
for
Cow
<
'a
,
T
,
B
>
where
B
:
Hash
<
S
>
+
ToOwned
<
T
>
{
#[inline]
fn
hash
(
&
self
,
state
:
&
mut
S
)
{
Hash
::
hash
(
&**
self
,
state
)
}
}
}
#[cfg(not(stage0))]
mod
impls
{
use
prelude
::
*
;
use
borrow
::{
Cow
,
ToOwned
};
use
slice
;
use
super
::
*
;
...
...
@@ -399,4 +388,119 @@ fn hash_slice<H: Hasher>(data: &[$ty], state: &mut H) {
}
)
*
}
}
impl_write!
{
(
u8
,
write_u8
),
(
u16
,
write_u16
),
(
u32
,
write_u32
),
(
u64
,
write_u64
),
(
usize
,
write_usize
),
(
i8
,
write_i8
),
(
i16
,
write_i16
),
(
i32
,
write_i32
),
(
i64
,
write_i64
),
(
isize
,
write_isize
),
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
Hash
for
bool
{
fn
hash
<
H
:
Hasher
>
(
&
self
,
state
:
&
mut
H
)
{
state
.write_u8
(
*
self
as
u8
)
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
Hash
for
char
{
fn
hash
<
H
:
Hasher
>
(
&
self
,
state
:
&
mut
H
)
{
state
.write_u32
(
*
self
as
u32
)
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
Hash
for
str
{
fn
hash
<
H
:
Hasher
>
(
&
self
,
state
:
&
mut
H
)
{
state
.write
(
self
.as_bytes
());
state
.write_u8
(
0xff
)
}
}
macro_rules!
impl_hash_tuple
{
()
=>
(
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
Hash
for
()
{
fn
hash
<
H
:
Hasher
>
(
&
self
,
_
state
:
&
mut
H
)
{}
}
);
(
$
(
$name:ident
)
+
)
=>
(
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
$
(
$name
:
Hash
),
*>
Hash
for
(
$
(
$name
,)
*
)
{
#[allow(non_snake_case)]
fn
hash
<
S
:
Hasher
>
(
&
self
,
state
:
&
mut
S
)
{
let
(
$
(
ref
$name
,)
*
)
=
*
self
;
$
(
$name
.hash
(
state
);)
*
}
}
);
}
impl_hash_tuple!
{}
impl_hash_tuple!
{
A
}
impl_hash_tuple!
{
A
B
}
impl_hash_tuple!
{
A
B
C
}
impl_hash_tuple!
{
A
B
C
D
}
impl_hash_tuple!
{
A
B
C
D
E
}
impl_hash_tuple!
{
A
B
C
D
E
F
}
impl_hash_tuple!
{
A
B
C
D
E
F
G
}
impl_hash_tuple!
{
A
B
C
D
E
F
G
H
}
impl_hash_tuple!
{
A
B
C
D
E
F
G
H
I
}
impl_hash_tuple!
{
A
B
C
D
E
F
G
H
I
J
}
impl_hash_tuple!
{
A
B
C
D
E
F
G
H
I
J
K
}
impl_hash_tuple!
{
A
B
C
D
E
F
G
H
I
J
K
L
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
:
Hash
>
Hash
for
[
T
]
{
fn
hash
<
H
:
Hasher
>
(
&
self
,
state
:
&
mut
H
)
{
self
.len
()
.hash
(
state
);
Hash
::
hash_slice
(
self
,
state
)
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
'a
,
T
:
?
Sized
+
Hash
>
Hash
for
&
'a
T
{
fn
hash
<
H
:
Hasher
>
(
&
self
,
state
:
&
mut
H
)
{
(
**
self
)
.hash
(
state
);
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
'a
,
T
:
?
Sized
+
Hash
>
Hash
for
&
'a
mut
T
{
fn
hash
<
H
:
Hasher
>
(
&
self
,
state
:
&
mut
H
)
{
(
**
self
)
.hash
(
state
);
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
>
Hash
for
*
const
T
{
fn
hash
<
H
:
Hasher
>
(
&
self
,
state
:
&
mut
H
)
{
state
.write_usize
(
*
self
as
usize
)
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
>
Hash
for
*
mut
T
{
fn
hash
<
H
:
Hasher
>
(
&
self
,
state
:
&
mut
H
)
{
state
.write_usize
(
*
self
as
usize
)
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
'a
,
T
,
B
:
?
Sized
>
Hash
for
Cow
<
'a
,
T
,
B
>
where
B
:
Hash
+
ToOwned
<
T
>
{
fn
hash
<
H
:
Hasher
>
(
&
self
,
state
:
&
mut
H
)
{
Hash
::
hash
(
&**
self
,
state
)
}
}
}
src/libstd/collections/hash/map_stage0.rs
浏览文件 @
3e7a04cb
...
...
@@ -14,7 +14,7 @@
use
self
::
SearchResult
::
*
;
use
self
::
VacantEntryState
::
*
;
use
borrow
::
Borrow
From
;
use
borrow
::
Borrow
;
use
clone
::
Clone
;
use
cmp
::{
max
,
Eq
,
PartialEq
};
use
default
::
Default
;
...
...
@@ -453,18 +453,18 @@ fn make_hash<X: ?Sized>(&self, x: &X) -> SafeHash where X: Hash<H> {
/// If you already have the hash for the key lying around, use
/// search_hashed.
fn
search
<
'a
,
Q
:
?
Sized
>
(
&
'a
self
,
q
:
&
Q
)
->
Option
<
FullBucketImm
<
'a
,
K
,
V
>>
where
Q
:
BorrowFrom
<
K
>
+
Eq
+
Hash
<
H
>
where
K
:
Borrow
<
Q
>
,
Q
:
Eq
+
Hash
<
H
>
{
let
hash
=
self
.make_hash
(
q
);
search_hashed
(
&
self
.table
,
hash
,
|
k
|
q
.eq
(
BorrowFrom
::
borrow_from
(
k
)))
search_hashed
(
&
self
.table
,
hash
,
|
k
|
q
.eq
(
k
.borrow
(
)))
.into_option
()
}
fn
search_mut
<
'a
,
Q
:
?
Sized
>
(
&
'a
mut
self
,
q
:
&
Q
)
->
Option
<
FullBucketMut
<
'a
,
K
,
V
>>
where
Q
:
BorrowFrom
<
K
>
+
Eq
+
Hash
<
H
>
where
K
:
Borrow
<
Q
>
,
Q
:
Eq
+
Hash
<
H
>
{
let
hash
=
self
.make_hash
(
q
);
search_hashed
(
&
mut
self
.table
,
hash
,
|
k
|
q
.eq
(
BorrowFrom
::
borrow_from
(
k
)))
search_hashed
(
&
mut
self
.table
,
hash
,
|
k
|
q
.eq
(
k
.borrow
(
)))
.into_option
()
}
...
...
@@ -1037,7 +1037,7 @@ pub fn clear(&mut self) {
/// ```
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
fn
get
<
Q
:
?
Sized
>
(
&
self
,
k
:
&
Q
)
->
Option
<&
V
>
where
Q
:
Hash
<
H
>
+
Eq
+
BorrowFrom
<
K
>
where
K
:
Borrow
<
Q
>
,
Q
:
Hash
<
H
>
+
Eq
{
self
.search
(
k
)
.map
(|
bucket
|
bucket
.into_refs
()
.1
)
}
...
...
@@ -1060,7 +1060,7 @@ pub fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V>
/// ```
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
fn
contains_key
<
Q
:
?
Sized
>
(
&
self
,
k
:
&
Q
)
->
bool
where
Q
:
Hash
<
H
>
+
Eq
+
BorrowFrom
<
K
>
where
K
:
Borrow
<
Q
>
,
Q
:
Hash
<
H
>
+
Eq
{
self
.search
(
k
)
.is_some
()
}
...
...
@@ -1086,7 +1086,7 @@ pub fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool
/// ```
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
fn
get_mut
<
Q
:
?
Sized
>
(
&
mut
self
,
k
:
&
Q
)
->
Option
<&
mut
V
>
where
Q
:
Hash
<
H
>
+
Eq
+
BorrowFrom
<
K
>
where
K
:
Borrow
<
Q
>
,
Q
:
Hash
<
H
>
+
Eq
{
self
.search_mut
(
k
)
.map
(|
bucket
|
bucket
.into_mut_refs
()
.1
)
}
...
...
@@ -1138,7 +1138,7 @@ pub fn insert(&mut self, k: K, v: V) -> Option<V> {
/// ```
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
fn
remove
<
Q
:
?
Sized
>
(
&
mut
self
,
k
:
&
Q
)
->
Option
<
V
>
where
Q
:
Hash
<
H
>
+
Eq
+
BorrowFrom
<
K
>
where
K
:
Borrow
<
Q
>
,
Q
:
Hash
<
H
>
+
Eq
{
if
self
.table
.size
()
==
0
{
return
None
...
...
@@ -1247,8 +1247,8 @@ fn default() -> HashMap<K, V, S> {
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
K
,
Q
:
?
Sized
,
V
,
S
,
H
>
Index
<
Q
>
for
HashMap
<
K
,
V
,
S
>
where
K
:
Eq
+
Hash
<
H
>
,
Q
:
Eq
+
Hash
<
H
>
+
BorrowFrom
<
K
>
,
where
K
:
Eq
+
Hash
<
H
>
+
Borrow
<
Q
>
,
Q
:
Eq
+
Hash
<
H
>
,
S
:
HashState
<
Hasher
=
H
>
,
H
:
hash
::
Hasher
<
Output
=
u64
>
{
...
...
@@ -1262,8 +1262,8 @@ fn index<'a>(&'a self, index: &Q) -> &'a V {
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
K
,
V
,
S
,
H
,
Q
:
?
Sized
>
IndexMut
<
Q
>
for
HashMap
<
K
,
V
,
S
>
where
K
:
Eq
+
Hash
<
H
>
,
Q
:
Eq
+
Hash
<
H
>
+
BorrowFrom
<
K
>
,
where
K
:
Eq
+
Hash
<
H
>
+
Borrow
<
Q
>
,
Q
:
Eq
+
Hash
<
H
>
,
S
:
HashState
<
Hasher
=
H
>
,
H
:
hash
::
Hasher
<
Output
=
u64
>
{
...
...
src/libstd/collections/hash/set_stage0.rs
浏览文件 @
3e7a04cb
...
...
@@ -10,7 +10,7 @@
//
// ignore-lexer-test FIXME #15883
use
borrow
::
Borrow
From
;
use
borrow
::
Borrow
;
use
clone
::
Clone
;
use
cmp
::{
Eq
,
PartialEq
};
use
core
::
marker
::
Sized
;
...
...
@@ -462,7 +462,7 @@ pub fn clear(&mut self) { self.map.clear() }
/// ```
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
fn
contains
<
Q
:
?
Sized
>
(
&
self
,
value
:
&
Q
)
->
bool
where
Q
:
BorrowFrom
<
T
>
+
Hash
<
H
>
+
Eq
where
T
:
Borrow
<
Q
>
,
Q
:
Hash
<
H
>
+
Eq
{
self
.map
.contains_key
(
value
)
}
...
...
@@ -572,7 +572,7 @@ pub fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()).is_none(
/// ```
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
fn
remove
<
Q
:
?
Sized
>
(
&
mut
self
,
value
:
&
Q
)
->
bool
where
Q
:
BorrowFrom
<
T
>
+
Hash
<
H
>
+
Eq
where
T
:
Borrow
<
Q
>
,
Q
:
Hash
<
H
>
+
Eq
{
self
.map
.remove
(
value
)
.is_some
()
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录