Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f2f4a5c8
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,发现更多精彩内容 >>
提交
f2f4a5c8
编写于
8月 09, 2015
作者:
G
Guillaume Gomez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add HashSet and HashMap tests
上级
a4e42338
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
26 deletion
+22
-26
src/libstd/collections/hash/set.rs
src/libstd/collections/hash/set.rs
+1
-22
src/libstd/collections/hash/table.rs
src/libstd/collections/hash/table.rs
+14
-3
src/test/run-pass/sync-send-iterators-in-libcollections.rs
src/test/run-pass/sync-send-iterators-in-libcollections.rs
+7
-1
未找到文件。
src/libstd/collections/hash/set.rs
浏览文件 @
f2f4a5c8
...
...
@@ -11,7 +11,7 @@
use
borrow
::
Borrow
;
use
clone
::
Clone
;
use
cmp
::{
Eq
,
PartialEq
};
use
core
::
marker
::
{
Sized
,
Send
,
Sync
}
;
use
core
::
marker
::
Sized
;
use
default
::
Default
;
use
fmt
::
Debug
;
use
fmt
;
...
...
@@ -764,27 +764,18 @@ pub struct Iter<'a, K: 'a> {
iter
:
Keys
<
'a
,
K
,
()
>
}
unsafe
impl
<
'a
,
K
:
Send
>
Send
for
Iter
<
'a
,
K
>
{}
unsafe
impl
<
'a
,
K
:
Sync
>
Sync
for
Iter
<
'a
,
K
>
{}
/// HashSet move iterator
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
struct
IntoIter
<
K
>
{
iter
:
Map
<
map
::
IntoIter
<
K
,
()
>
,
fn
((
K
,
()))
->
K
>
}
unsafe
impl
<
K
:
Send
>
Send
for
IntoIter
<
K
>
{}
unsafe
impl
<
K
:
Sync
>
Sync
for
IntoIter
<
K
>
{}
/// HashSet drain iterator
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
struct
Drain
<
'a
,
K
:
'a
>
{
iter
:
Map
<
map
::
Drain
<
'a
,
K
,
()
>
,
fn
((
K
,
()))
->
K
>
,
}
unsafe
impl
<
'a
,
K
:
Send
>
Send
for
Drain
<
'a
,
K
>
{}
unsafe
impl
<
'a
,
K
:
Sync
>
Sync
for
Drain
<
'a
,
K
>
{}
/// Intersection iterator
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
struct
Intersection
<
'a
,
T
:
'a
,
S
:
'a
>
{
...
...
@@ -794,9 +785,6 @@ pub struct Intersection<'a, T: 'a, S: 'a> {
other
:
&
'a
HashSet
<
T
,
S
>
,
}
unsafe
impl
<
'a
,
K
:
Send
,
S
:
Send
>
Send
for
Intersection
<
'a
,
K
,
S
>
{}
unsafe
impl
<
'a
,
K
:
Sync
,
S
:
Send
>
Sync
for
Intersection
<
'a
,
K
,
S
>
{}
/// Difference iterator
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
struct
Difference
<
'a
,
T
:
'a
,
S
:
'a
>
{
...
...
@@ -806,27 +794,18 @@ pub struct Difference<'a, T: 'a, S: 'a> {
other
:
&
'a
HashSet
<
T
,
S
>
,
}
unsafe
impl
<
'a
,
K
:
Send
,
S
:
Send
>
Send
for
Difference
<
'a
,
K
,
S
>
{}
unsafe
impl
<
'a
,
K
:
Sync
,
S
:
Send
>
Sync
for
Difference
<
'a
,
K
,
S
>
{}
/// Symmetric difference iterator.
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
struct
SymmetricDifference
<
'a
,
T
:
'a
,
S
:
'a
>
{
iter
:
Chain
<
Difference
<
'a
,
T
,
S
>
,
Difference
<
'a
,
T
,
S
>>
}
unsafe
impl
<
'a
,
K
:
Send
,
S
:
Send
>
Send
for
SymmetricDifference
<
'a
,
K
,
S
>
{}
unsafe
impl
<
'a
,
K
:
Sync
,
S
:
Send
>
Sync
for
SymmetricDifference
<
'a
,
K
,
S
>
{}
/// Set union iterator.
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
struct
Union
<
'a
,
T
:
'a
,
S
:
'a
>
{
iter
:
Chain
<
Iter
<
'a
,
T
>
,
Difference
<
'a
,
T
,
S
>>
}
unsafe
impl
<
'a
,
K
:
Send
,
S
:
Send
>
Send
for
Union
<
'a
,
K
,
S
>
{}
unsafe
impl
<
'a
,
K
:
Sync
,
S
:
Send
>
Sync
for
Union
<
'a
,
K
,
S
>
{}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
'a
,
T
,
S
>
IntoIterator
for
&
'a
HashSet
<
T
,
S
>
where
T
:
Eq
+
Hash
,
S
:
HashState
...
...
src/libstd/collections/hash/table.rs
浏览文件 @
f2f4a5c8
...
...
@@ -741,9 +741,6 @@ struct RawBuckets<'a, K, V> {
marker
:
marker
::
PhantomData
<&
'a
()
>
,
}
unsafe
impl
<
'a
,
K
:
Send
,
V
:
Send
>
Send
for
RawBuckets
<
'a
,
K
,
V
>
{}
unsafe
impl
<
'a
,
K
:
Sync
,
V
:
Sync
>
Sync
for
RawBuckets
<
'a
,
K
,
V
>
{}
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
impl
<
'a
,
K
,
V
>
Clone
for
RawBuckets
<
'a
,
K
,
V
>
{
fn
clone
(
&
self
)
->
RawBuckets
<
'a
,
K
,
V
>
{
...
...
@@ -821,6 +818,9 @@ pub struct Iter<'a, K: 'a, V: 'a> {
elems_left
:
usize
,
}
unsafe
impl
<
'a
,
K
:
Sync
,
V
:
Sync
>
Sync
for
Iter
<
'a
,
K
,
V
>
{}
unsafe
impl
<
'a
,
K
:
Sync
,
V
:
Sync
>
Send
for
Iter
<
'a
,
K
,
V
>
{}
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
impl
<
'a
,
K
,
V
>
Clone
for
Iter
<
'a
,
K
,
V
>
{
fn
clone
(
&
self
)
->
Iter
<
'a
,
K
,
V
>
{
...
...
@@ -838,18 +838,29 @@ pub struct IterMut<'a, K: 'a, V: 'a> {
elems_left
:
usize
,
}
unsafe
impl
<
'a
,
K
:
Sync
,
V
:
Sync
>
Sync
for
IterMut
<
'a
,
K
,
V
>
{}
// Both K: Sync and K: Send are correct for IterMut's Send impl,
// but Send is the more useful bound
unsafe
impl
<
'a
,
K
:
Send
,
V
:
Send
>
Send
for
IterMut
<
'a
,
K
,
V
>
{}
/// Iterator over the entries in a table, consuming the table.
pub
struct
IntoIter
<
K
,
V
>
{
table
:
RawTable
<
K
,
V
>
,
iter
:
RawBuckets
<
'static
,
K
,
V
>
}
unsafe
impl
<
K
:
Sync
,
V
:
Sync
>
Sync
for
IntoIter
<
K
,
V
>
{}
unsafe
impl
<
K
:
Send
,
V
:
Send
>
Send
for
IntoIter
<
K
,
V
>
{}
/// Iterator over the entries in a table, clearing the table.
pub
struct
Drain
<
'a
,
K
:
'a
,
V
:
'a
>
{
table
:
&
'a
mut
RawTable
<
K
,
V
>
,
iter
:
RawBuckets
<
'static
,
K
,
V
>
,
}
unsafe
impl
<
'a
,
K
:
Sync
,
V
:
Sync
>
Sync
for
Drain
<
'a
,
K
,
V
>
{}
unsafe
impl
<
'a
,
K
:
Send
,
V
:
Send
>
Send
for
Drain
<
'a
,
K
,
V
>
{}
impl
<
'a
,
K
,
V
>
Iterator
for
Iter
<
'a
,
K
,
V
>
{
type
Item
=
(
&
'a
K
,
&
'a
V
);
...
...
src/test/run-pass/sync-send-iterators-in-libcollections.rs
浏览文件 @
f2f4a5c8
...
...
@@ -26,6 +26,7 @@
use
collections
::
VecDeque
;
use
collections
::
VecMap
;
use
std
::
collections
::
HashMap
;
use
std
::
collections
::
HashSet
;
use
collections
::
Bound
::
Included
;
use
collections
::
enum_set
::
CLike
;
...
...
@@ -78,7 +79,12 @@ fn main() {
is_sync_send!
(
BTreeSet
::
<
usize
>
::
new
(),
intersection
(
&
BTreeSet
::
<
usize
>
::
new
()));
is_sync_send!
(
BTreeSet
::
<
usize
>
::
new
(),
union
(
&
BTreeSet
::
<
usize
>
::
new
()));
all_sync_send!
(
HashMap
::
<
usize
,
usize
>
::
new
(),
keys
,
values
,
iter
,
iter_mut
);
all_sync_send!
(
HashMap
::
<
usize
,
usize
>
::
new
(),
iter
,
iter_mut
,
drain
,
into_iter
,
keys
,
values
);
all_sync_send!
(
HashSet
::
<
usize
>
::
new
(),
iter
,
drain
,
into_iter
);
is_sync_send!
(
HashSet
::
<
usize
>
::
new
(),
difference
(
&
HashSet
::
<
usize
>
::
new
()));
is_sync_send!
(
HashSet
::
<
usize
>
::
new
(),
symmetric_difference
(
&
HashSet
::
<
usize
>
::
new
()));
is_sync_send!
(
HashSet
::
<
usize
>
::
new
(),
intersection
(
&
HashSet
::
<
usize
>
::
new
()));
is_sync_send!
(
HashSet
::
<
usize
>
::
new
(),
union
(
&
HashSet
::
<
usize
>
::
new
()));
all_sync_send!
(
LinkedList
::
<
usize
>
::
new
(),
iter
,
iter_mut
,
into_iter
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录