Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
06bec77f
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,发现更多精彩内容 >>
提交
06bec77f
编写于
6月 19, 2013
作者:
D
Daniel Micay
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
replace vec::find with the IteratorUtil method
上级
883c966d
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
16 addition
and
57 deletion
+16
-57
src/librustc/middle/check_match.rs
src/librustc/middle/check_match.rs
+1
-1
src/librustc/middle/trans/monomorphize.rs
src/librustc/middle/trans/monomorphize.rs
+1
-1
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+3
-2
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/check/mod.rs
+1
-1
src/librustdoc/attr_pass.rs
src/librustdoc/attr_pass.rs
+1
-1
src/librustdoc/config.rs
src/librustdoc/config.rs
+4
-5
src/librustdoc/tystr_pass.rs
src/librustdoc/tystr_pass.rs
+4
-4
src/libstd/str.rs
src/libstd/str.rs
+1
-1
src/libstd/vec.rs
src/libstd/vec.rs
+0
-41
未找到文件。
src/librustc/middle/check_match.rs
浏览文件 @
06bec77f
...
...
@@ -456,7 +456,7 @@ pub fn ctor_arity(cx: @MatchCheckCtxt, ctor: &ctor, ty: ty::t) -> uint {
ty
::
ty_enum
(
eid
,
_
)
=>
{
let
id
=
match
*
ctor
{
variant
(
id
)
=>
id
,
_
=>
fail
!
(
"impossible case"
)
};
match
vec
::
find
(
*
ty
::
enum_variants
(
cx
.tcx
,
eid
),
|
v
|
v
.id
==
id
)
{
match
ty
::
enum_variants
(
cx
.tcx
,
eid
)
.iter
()
.find_
(
|
v
|
v
.id
==
id
)
{
Some
(
v
)
=>
v
.args
.len
(),
None
=>
fail
!
(
"impossible case"
)
}
...
...
src/librustc/middle/trans/monomorphize.rs
浏览文件 @
06bec77f
...
...
@@ -209,7 +209,7 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
}
ast_map
::
node_variant
(
ref
v
,
enum_item
,
_
)
=>
{
let
tvs
=
ty
::
enum_variants
(
ccx
.tcx
,
local_def
(
enum_item
.id
));
let
this_tv
=
vec
::
find
(
*
tvs
,
|
tv
|
{
tv
.id.node
==
fn_id
.node
})
.get
();
let
this_tv
=
*
tvs
.iter
()
.find_
(
|
tv
|
{
tv
.id.node
==
fn_id
.node
})
.get
();
let
d
=
mk_lldecl
();
set_inline_hint
(
d
);
match
v
.node.kind
{
...
...
src/librustc/middle/ty.rs
浏览文件 @
06bec77f
...
...
@@ -4128,9 +4128,10 @@ pub fn lookup_struct_field(cx: ctxt,
parent
:
ast
::
def_id
,
field_id
:
ast
::
def_id
)
->
field_ty
{
match
vec
::
find
(
lookup_struct_fields
(
cx
,
parent
),
let
r
=
lookup_struct_fields
(
cx
,
parent
);
match
r
.iter
()
.find_
(
|
f
|
f
.id.node
==
field_id
.node
)
{
Some
(
t
)
=>
t
,
Some
(
t
)
=>
*
t
,
None
=>
cx
.sess
.bug
(
"struct ID not found in parent's fields"
)
}
}
...
...
src/librustc/middle/typeck/check/mod.rs
浏览文件 @
06bec77f
...
...
@@ -1107,7 +1107,7 @@ pub fn lookup_field_ty(tcx: ty::ctxt,
fieldname
:
ast
::
ident
,
substs
:
&
ty
::
substs
)
->
Option
<
ty
::
t
>
{
let
o_field
=
vec
::
find
(
items
,
|
f
|
f
.ident
==
fieldname
);
let
o_field
=
items
.iter
()
.find_
(
|
f
|
f
.ident
==
fieldname
);
do
o_field
.map
()
|
f
|
{
ty
::
lookup_field_type
(
tcx
,
class_id
,
f
.id
,
substs
)
}
...
...
src/librustdoc/attr_pass.rs
浏览文件 @
06bec77f
...
...
@@ -135,7 +135,7 @@ fn fold_enum(
node
:
ast
::
item_enum
(
ref
enum_definition
,
_
),
_
},
_
)
=>
{
let
ast_variant
=
vec
::
find
(
enum_definition
.variants
,
|
v
|
{
copy
*
enum_definition
.variants
.iter
()
.find_
(
|
v
|
{
to_str
(
v
.node.name
)
==
variant
.name
})
.get
();
...
...
src/librustdoc/config.rs
浏览文件 @
06bec77f
...
...
@@ -230,16 +230,15 @@ pub fn maybe_find_pandoc(
}
};
let
pandoc
=
do
vec
::
find
(
possible_pandocs
)
|
pandoc
|
{
let
pandoc
=
do
possible_pandocs
.iter
()
.find_
|
&
pandoc
|
{
let
output
=
process_output
(
*
pandoc
,
[
~
"--version"
]);
debug!
(
"testing pandoc cmd %s: %?"
,
*
pandoc
,
output
);
output
.status
==
0
};
if
pandoc
.is_some
()
{
result
::
Ok
(
pandoc
)
}
else
{
result
::
Err
(
~
"couldn't find pandoc"
)
match
pandoc
{
Some
(
x
)
=>
Ok
(
Some
(
copy
*
x
)),
// ugly, shouldn't be doubly wrapped
None
=>
Err
(
~
"couldn't find pandoc"
)
}
}
...
...
src/librustdoc/tystr_pass.rs
浏览文件 @
06bec77f
...
...
@@ -124,7 +124,7 @@ fn fold_enum(
node
:
ast
::
item_enum
(
ref
enum_definition
,
_
),
_
},
_
)
=>
{
let
ast_variant
=
do
vec
::
find
(
enum_definition
.variants
)
|
v
|
{
copy
*
do
enum_definition
.variants
.iter
()
.find_
|
v
|
{
to_str
(
v
.node.name
)
==
variant
.name
}
.get
();
...
...
@@ -178,14 +178,14 @@ fn get_method_sig(
ast_map
::
node_item
(
@
ast
::
item
{
node
:
ast
::
item_trait
(
_
,
_
,
ref
methods
),
_
},
_
)
=>
{
match
vec
::
find
(
*
methods
,
|
method
|
{
match
methods
.iter
()
.find_
(|
&
method
|
{
match
copy
*
method
{
ast
::
required
(
ty_m
)
=>
to_str
(
ty_m
.ident
)
==
method_name
,
ast
::
provided
(
m
)
=>
to_str
(
m
.ident
)
==
method_name
,
}
})
{
Some
(
method
)
=>
{
match
method
{
match
copy
*
method
{
ast
::
required
(
ty_m
)
=>
{
Some
(
pprust
::
fun_to_str
(
&
ty_m
.decl
,
...
...
@@ -214,7 +214,7 @@ fn get_method_sig(
ast_map
::
node_item
(
@
ast
::
item
{
node
:
ast
::
item_impl
(
_
,
_
,
_
,
ref
methods
),
_
},
_
)
=>
{
match
vec
::
find
(
*
methods
,
|
method
|
{
match
methods
.iter
()
.find_
(
|
method
|
{
to_str
(
method
.ident
)
==
method_name
})
{
Some
(
method
)
=>
{
...
...
src/libstd/str.rs
浏览文件 @
06bec77f
...
...
@@ -60,7 +60,7 @@ pub fn from_bytes(vv: &[u8]) -> ~str {
use
str
::
not_utf8
::
cond
;
if
!
is_utf8
(
vv
)
{
let
first_bad_byte
=
vec
::
find
(
vv
,
|
b
|
!
is_utf8
([
*
b
]))
.get
();
let
first_bad_byte
=
*
vv
.iter
()
.find_
(|
&
b
|
!
is_utf8
([
*
b
]))
.get
();
cond
.raise
(
fmt!
(
"from_bytes: input is not UTF-8; first bad byte is %u"
,
first_bad_byte
as
uint
))
}
...
...
src/libstd/vec.rs
浏览文件 @
06bec77f
...
...
@@ -1056,17 +1056,6 @@ pub fn contains<T:Eq>(v: &[T], x: &T) -> bool {
false
}
/**
* Search for the first element that matches a given predicate
*
* Apply function `f` to each element of `v`, starting from the first.
* When function `f` returns true then an option containing the element
* is returned. If `f` matches no elements then none is returned.
*/
pub
fn
find
<
T
:
Copy
>
(
v
:
&
[
T
],
f
:
&
fn
(
t
:
&
T
)
->
bool
)
->
Option
<
T
>
{
find_between
(
v
,
0u
,
v
.len
(),
f
)
}
/**
* Search for the first element that matches a given predicate within a range
*
...
...
@@ -3163,18 +3152,6 @@ fn test_position_between() {
assert
!
(
position_between
(
v
,
4u
,
4u
,
f
)
.is_none
());
}
#[test]
fn
test_find
()
{
assert
!
(
find
([],
f
)
.is_none
());
fn
f
(
xy
:
&
(
int
,
char
))
->
bool
{
let
(
_
x
,
y
)
=
*
xy
;
y
==
'b'
}
fn
g
(
xy
:
&
(
int
,
char
))
->
bool
{
let
(
_
x
,
y
)
=
*
xy
;
y
==
'd'
}
let
v
=
~
[(
0
,
'a'
),
(
1
,
'b'
),
(
2
,
'c'
),
(
3
,
'b'
)];
assert_eq!
(
find
(
v
,
f
),
Some
((
1
,
'b'
)));
assert
!
(
find
(
v
,
g
)
.is_none
());
}
#[test]
fn
test_find_between
()
{
assert
!
(
find_between
([],
0u
,
0u
,
f
)
.is_none
());
...
...
@@ -3205,8 +3182,6 @@ fn test_find_between() {
#[test]
fn
test_rposition
()
{
assert
!
(
find
([],
f
)
.is_none
());
fn
f
(
xy
:
&
(
int
,
char
))
->
bool
{
let
(
_
x
,
y
)
=
*
xy
;
y
==
'b'
}
fn
g
(
xy
:
&
(
int
,
char
))
->
bool
{
let
(
_
x
,
y
)
=
*
xy
;
y
==
'd'
}
let
v
=
~
[(
0
,
'a'
),
(
1
,
'b'
),
(
2
,
'c'
),
(
3
,
'b'
)];
...
...
@@ -3838,22 +3813,6 @@ fn test_filter_fail() {
};
}
#[test]
#[ignore(windows)]
#[should_fail]
#[allow(non_implicitly_copyable_typarams)]
fn
test_find_fail
()
{
let
v
=
[(
~
0
,
@
0
),
(
~
0
,
@
0
),
(
~
0
,
@
0
),
(
~
0
,
@
0
)];
let
mut
i
=
0
;
do
find
(
v
)
|
_
elt
|
{
if
i
==
2
{
fail
!
()
}
i
+=
0
;
false
};
}
#[test]
#[ignore(windows)]
#[should_fail]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录