Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
5e13d19c
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
5e13d19c
编写于
1月 23, 2012
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
s/block()/fn()/g
上级
04351a84
变更
79
隐藏空白更改
内联
并排
Showing
79 changed file
with
152 addition
and
155 deletion
+152
-155
src/cargo/cargo.rs
src/cargo/cargo.rs
+1
-1
src/comp/metadata/cstore.rs
src/comp/metadata/cstore.rs
+1
-1
src/comp/metadata/decoder.rs
src/comp/metadata/decoder.rs
+1
-1
src/comp/metadata/encoder.rs
src/comp/metadata/encoder.rs
+1
-1
src/comp/metadata/tydecode.rs
src/comp/metadata/tydecode.rs
+2
-2
src/comp/middle/alias.rs
src/comp/middle/alias.rs
+1
-1
src/comp/middle/debuginfo.rs
src/comp/middle/debuginfo.rs
+1
-1
src/comp/middle/kind.rs
src/comp/middle/kind.rs
+1
-1
src/comp/middle/last_use.rs
src/comp/middle/last_use.rs
+1
-1
src/comp/middle/lint.rs
src/comp/middle/lint.rs
+1
-1
src/comp/middle/pat_util.rs
src/comp/middle/pat_util.rs
+1
-1
src/comp/middle/resolve.rs
src/comp/middle/resolve.rs
+2
-2
src/comp/middle/trans.rs
src/comp/middle/trans.rs
+4
-4
src/comp/middle/trans_closure.rs
src/comp/middle/trans_closure.rs
+2
-2
src/comp/middle/trans_impl.rs
src/comp/middle/trans_impl.rs
+1
-1
src/comp/middle/trans_vec.rs
src/comp/middle/trans_vec.rs
+1
-1
src/comp/middle/tstate/auxiliary.rs
src/comp/middle/tstate/auxiliary.rs
+1
-1
src/comp/middle/ty.rs
src/comp/middle/ty.rs
+4
-5
src/comp/syntax/ext/simplext.rs
src/comp/syntax/ext/simplext.rs
+2
-2
src/comp/syntax/parse/parser.rs
src/comp/syntax/parse/parser.rs
+8
-14
src/comp/syntax/print/pprust.rs
src/comp/syntax/print/pprust.rs
+3
-3
src/comp/util/filesearch.rs
src/comp/util/filesearch.rs
+1
-1
src/compiletest/header.rs
src/compiletest/header.rs
+1
-1
src/fuzzer/fuzzer.rs
src/fuzzer/fuzzer.rs
+1
-1
src/libcore/bool.rs
src/libcore/bool.rs
+1
-1
src/libcore/either.rs
src/libcore/either.rs
+1
-1
src/libcore/int.rs
src/libcore/int.rs
+1
-1
src/libcore/option.rs
src/libcore/option.rs
+3
-3
src/libcore/result.rs
src/libcore/result.rs
+1
-1
src/libcore/str.rs
src/libcore/str.rs
+4
-4
src/libcore/u32.rs
src/libcore/u32.rs
+1
-1
src/libcore/u64.rs
src/libcore/u64.rs
+1
-1
src/libcore/u8.rs
src/libcore/u8.rs
+1
-1
src/libcore/uint.rs
src/libcore/uint.rs
+2
-2
src/libcore/vec.rs
src/libcore/vec.rs
+20
-20
src/libstd/bitv.rs
src/libstd/bitv.rs
+1
-1
src/libstd/ebml.rs
src/libstd/ebml.rs
+2
-2
src/libstd/four.rs
src/libstd/four.rs
+1
-1
src/libstd/fun_treemap.rs
src/libstd/fun_treemap.rs
+1
-1
src/libstd/io.rs
src/libstd/io.rs
+3
-3
src/libstd/list.rs
src/libstd/list.rs
+3
-3
src/libstd/map.rs
src/libstd/map.rs
+9
-9
src/libstd/md4.rs
src/libstd/md4.rs
+1
-1
src/libstd/rope.rs
src/libstd/rope.rs
+5
-5
src/libstd/smallintmap.rs
src/libstd/smallintmap.rs
+3
-3
src/libstd/sort.rs
src/libstd/sort.rs
+1
-1
src/libstd/treemap.rs
src/libstd/treemap.rs
+1
-1
src/libstd/tri.rs
src/libstd/tri.rs
+1
-1
src/test/bench/99bob-iter.rs
src/test/bench/99bob-iter.rs
+1
-1
src/test/compile-fail/block-arg-used-as-lambda-with-illegal-cap.rs
...compile-fail/block-arg-used-as-lambda-with-illegal-cap.rs
+1
-1
src/test/compile-fail/block-coerce-no.rs
src/test/compile-fail/block-coerce-no.rs
+2
-2
src/test/compile-fail/block-copy.rs
src/test/compile-fail/block-copy.rs
+2
-2
src/test/compile-fail/block-deinitializes-upvar.rs
src/test/compile-fail/block-deinitializes-upvar.rs
+1
-1
src/test/compile-fail/block-require-return.rs
src/test/compile-fail/block-require-return.rs
+1
-1
src/test/compile-fail/block-uninit.rs
src/test/compile-fail/block-uninit.rs
+2
-2
src/test/compile-fail/cap-clause-illegal-cap.rs
src/test/compile-fail/cap-clause-illegal-cap.rs
+1
-1
src/test/compile-fail/lambda-mutate-nested.rs
src/test/compile-fail/lambda-mutate-nested.rs
+1
-1
src/test/pretty/block-arg-disambig.rs
src/test/pretty/block-arg-disambig.rs
+1
-1
src/test/run-fail/unwind-iter.rs
src/test/run-fail/unwind-iter.rs
+1
-1
src/test/run-fail/unwind-iter2.rs
src/test/run-fail/unwind-iter2.rs
+1
-1
src/test/run-fail/unwind-lambda.rs
src/test/run-fail/unwind-lambda.rs
+1
-1
src/test/run-pass/alt-phi.rs
src/test/run-pass/alt-phi.rs
+1
-1
src/test/run-pass/argument-passing.rs
src/test/run-pass/argument-passing.rs
+1
-1
src/test/run-pass/block-arg-call-as.rs
src/test/run-pass/block-arg-call-as.rs
+5
-1
src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs
src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs
+1
-1
src/test/run-pass/block-explicit-types.rs
src/test/run-pass/block-explicit-types.rs
+1
-1
src/test/run-pass/block-fn-coerce.rs
src/test/run-pass/block-fn-coerce.rs
+1
-1
src/test/run-pass/block-iter-1.rs
src/test/run-pass/block-iter-1.rs
+1
-1
src/test/run-pass/block-iter-2.rs
src/test/run-pass/block-iter-2.rs
+1
-1
src/test/run-pass/fn-bare-coerce-to-block.rs
src/test/run-pass/fn-bare-coerce-to-block.rs
+1
-1
src/test/run-pass/foreach-nested.rs
src/test/run-pass/foreach-nested.rs
+1
-1
src/test/run-pass/foreach-put-structured.rs
src/test/run-pass/foreach-put-structured.rs
+1
-1
src/test/run-pass/foreach-simple-outer-slot.rs
src/test/run-pass/foreach-simple-outer-slot.rs
+1
-1
src/test/run-pass/iface-generic.rs
src/test/run-pass/iface-generic.rs
+2
-2
src/test/run-pass/iter-range.rs
src/test/run-pass/iter-range.rs
+1
-1
src/test/run-pass/sendfn-is-a-block.rs
src/test/run-pass/sendfn-is-a-block.rs
+1
-1
src/test/run-pass/static-impl.rs
src/test/run-pass/static-impl.rs
+3
-3
src/test/run-pass/type-params-in-for-each.rs
src/test/run-pass/type-params-in-for-each.rs
+1
-1
src/test/run-pass/unchecked-predicates.rs
src/test/run-pass/unchecked-predicates.rs
+1
-1
未找到文件。
src/cargo/cargo.rs
浏览文件 @
5e13d19c
...
...
@@ -349,7 +349,7 @@ fn configure() -> cargo {
c
}
fn
for_each_package
(
c
:
cargo
,
b
:
block
(
source
,
package
))
{
fn
for_each_package
(
c
:
cargo
,
b
:
fn
(
source
,
package
))
{
c
.sources
.values
({
|
v
|
for
p
in
copy
v
.packages
{
b
(
v
,
p
);
...
...
src/comp/metadata/cstore.rs
浏览文件 @
5e13d19c
...
...
@@ -93,7 +93,7 @@ fn have_crate_data(cstore: cstore, cnum: ast::crate_num) -> bool {
ret
p
(
cstore
)
.metas
.contains_key
(
cnum
);
}
fn
iter_crate_data
(
cstore
:
cstore
,
i
:
block
(
ast
::
crate_num
,
crate_metadata
))
{
fn
iter_crate_data
(
cstore
:
cstore
,
i
:
fn
(
ast
::
crate_num
,
crate_metadata
))
{
p
(
cstore
)
.metas.items
{|
k
,
v
|
i
(
k
,
v
);};
}
...
...
src/comp/metadata/decoder.rs
浏览文件 @
5e13d19c
...
...
@@ -460,7 +460,7 @@ fn list_crate_items(bytes: @[u8], md: ebml::doc, out: io::writer) {
out
.write_str
(
"
\n
"
);
}
fn
iter_crate_items
(
bytes
:
@
[
u8
],
proc
:
block
(
str
,
ast
::
def_id
))
{
fn
iter_crate_items
(
bytes
:
@
[
u8
],
proc
:
fn
(
str
,
ast
::
def_id
))
{
let
md
=
ebml
::
new_doc
(
bytes
);
let
paths
=
ebml
::
get_doc
(
md
,
tag_paths
);
let
index
=
ebml
::
get_doc
(
paths
,
tag_index
);
...
...
src/comp/metadata/encoder.rs
浏览文件 @
5e13d19c
...
...
@@ -486,7 +486,7 @@ fn create_index<T: copy>(index: [entry<T>], hash_fn: fn@(T) -> uint) ->
}
fn
encode_index
<
T
>
(
ebml_w
:
ebml
::
writer
,
buckets
:
[
@
[
entry
<
T
>
]],
write_fn
:
block
(
io
::
writer
,
T
))
{
write_fn
:
fn
(
io
::
writer
,
T
))
{
let
writer
=
ebml_w
.writer
;
ebml
::
start_tag
(
ebml_w
,
tag_index
);
let
bucket_locs
:
[
uint
]
=
[];
...
...
src/comp/metadata/tydecode.rs
浏览文件 @
5e13d19c
...
...
@@ -16,7 +16,7 @@
// data buffer. Whatever format you choose should not contain pipe characters.
// Callback to translate defs to strs or back:
type
conv_did
=
block
(
ast
::
def_id
)
->
ast
::
def_id
;
type
conv_did
=
fn
(
ast
::
def_id
)
->
ast
::
def_id
;
type
pstate
=
{
data
:
@
[
u8
],
crate
:
int
,
mutable
pos
:
uint
,
tcx
:
ty
::
ctxt
};
...
...
@@ -138,7 +138,7 @@ fn parse_ty_constr_arg(st: @pstate) -> ast::constr_arg_general_<@path> {
}
fn
parse_constr
<
T
:
copy
>
(
st
:
@
pstate
,
conv
:
conv_did
,
pser
:
block
(
@
pstate
)
->
ast
::
constr_arg_general_
<
T
>
)
pser
:
fn
(
@
pstate
)
->
ast
::
constr_arg_general_
<
T
>
)
->
@
ty
::
constr_general
<
T
>
{
let
sp
=
ast_util
::
dummy_sp
();
// FIXME: use a real span
let
args
:
[
@
sp_constr_arg
<
T
>
]
=
[];
...
...
src/comp/middle/alias.rs
浏览文件 @
5e13d19c
...
...
@@ -436,7 +436,7 @@ fn check_if(c: @ast::expr, then: ast::blk, els: option::t<@ast::expr>,
*
sc
.invalid
=
append_invalid
(
*
sc
.invalid
,
then_invalid
,
orig_invalid
);
}
fn
check_loop
(
cx
:
ctx
,
sc
:
scope
,
checker
:
block
())
{
fn
check_loop
(
cx
:
ctx
,
sc
:
scope
,
checker
:
fn
())
{
let
orig_invalid
=
filter_invalid
(
*
sc
.invalid
,
sc
.bs
);
checker
();
let
new_invalid
=
filter_invalid
(
*
sc
.invalid
,
sc
.bs
);
...
...
src/comp/middle/debuginfo.rs
浏览文件 @
5e13d19c
...
...
@@ -140,7 +140,7 @@ fn md_from_metadata<T>(val: debug_metadata) -> T unsafe {
}
fn
cached_metadata
<
T
:
copy
>
(
cache
:
metadata_cache
,
mdtag
:
int
,
eq
:
block
(
md
:
T
)
->
bool
)
->
option
::
t
<
T
>
unsafe
{
eq
:
fn
(
md
:
T
)
->
bool
)
->
option
::
t
<
T
>
unsafe
{
if
cache
.contains_key
(
mdtag
)
{
let
items
=
cache
.get
(
mdtag
);
for
item
in
items
{
...
...
src/comp/middle/kind.rs
浏览文件 @
5e13d19c
...
...
@@ -58,7 +58,7 @@ fn check_crate(tcx: ty::ctxt, method_map: typeck::method_map,
// variables. `id` is the node_id for some expression that creates the
// closure.
fn
with_appropriate_checker
(
cx
:
ctx
,
id
:
node_id
,
b
:
block
(
fn
@
(
ctx
,
ty
::
t
,
sp
:
span
)))
{
b
:
fn
(
fn
@
(
ctx
,
ty
::
t
,
sp
:
span
)))
{
let
fty
=
ty
::
node_id_to_monotype
(
cx
.tcx
,
id
);
alt
ty
::
ty_fn_proto
(
cx
.tcx
,
fty
)
{
proto_uniq
{
b
(
check_send
);
}
...
...
src/comp/middle/last_use.rs
浏览文件 @
5e13d19c
...
...
@@ -203,7 +203,7 @@ fn visit_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
}
}
fn
visit_block
(
tp
:
block_type
,
cx
:
ctx
,
visit
:
block
())
{
fn
visit_block
(
tp
:
block_type
,
cx
:
ctx
,
visit
:
fn
())
{
let
local
=
@
{
type
:
tp
,
mutable
second
:
false
,
mutable
exits
:
[]};
cx
.blocks
=
cons
(
local
,
@
cx
.blocks
);
visit
();
...
...
src/comp/middle/lint.rs
浏览文件 @
5e13d19c
...
...
@@ -26,7 +26,7 @@ fn run(tcx: ty::ctxt, crate: @ast::crate, time_pass: bool) {
}
// FIXME: Copied from driver.rs, to work around a bug(#1566)
fn
time
(
do_it
:
bool
,
what
:
str
,
thunk
:
block
())
{
fn
time
(
do_it
:
bool
,
what
:
str
,
thunk
:
fn
())
{
if
!
do_it
{
ret
thunk
();
}
let
start
=
std
::
time
::
precise_time_s
();
thunk
();
...
...
src/comp/middle/pat_util.rs
浏览文件 @
5e13d19c
...
...
@@ -91,7 +91,7 @@ fn pat_id_map(tcx: ty::ctxt, pat: @pat) -> pat_id_map {
// This does *not* normalize. The pattern should be already normalized
// if you want to get a normalized pattern out of it.
// Could return a constrained type in order to express that (future work)
fn
pat_bindings
(
pat
:
@
pat
,
it
:
block
(
@
pat
))
{
fn
pat_bindings
(
pat
:
@
pat
,
it
:
fn
(
@
pat
))
{
alt
pat
.node
{
pat_ident
(
_
,
option
::
none
)
{
it
(
pat
);
}
pat_ident
(
_
,
option
::
some
(
sub
))
{
it
(
pat
);
pat_bindings
(
sub
,
it
);
}
...
...
src/comp/middle/resolve.rs
浏览文件 @
5e13d19c
...
...
@@ -632,7 +632,7 @@ fn resolve_constr(e: @env, c: @ast::constr, sc: scopes, _v: vt<scopes>) {
fn
resolve_import
(
e
:
env
,
defid
:
ast
::
def_id
,
name
:
ast
::
ident
,
ids
:
[
ast
::
ident
],
sp
:
codemap
::
span
,
sc
:
scopes
)
{
fn
register
(
e
:
env
,
id
:
node_id
,
cx
:
ctxt
,
sp
:
codemap
::
span
,
name
:
ast
::
ident
,
lookup
:
block
(
namespace
)
->
option
::
t
<
def
>
,
name
:
ast
::
ident
,
lookup
:
fn
(
namespace
)
->
option
::
t
<
def
>
,
impls
:
[
@
_
impl
])
{
let
val
=
lookup
(
ns_val
(
ns_any_value
)),
typ
=
lookup
(
ns_type
),
md
=
lookup
(
ns_module
);
...
...
@@ -1712,7 +1712,7 @@ fn add_name(ch: checker, sp: span, name: ident) {
fn
ident_id
(
&&
i
:
ident
)
->
ident
{
ret
i
;
}
fn
ensure_unique
<
T
>
(
e
:
env
,
sp
:
span
,
elts
:
[
T
],
id
:
block
(
T
)
->
ident
,
fn
ensure_unique
<
T
>
(
e
:
env
,
sp
:
span
,
elts
:
[
T
],
id
:
fn
(
T
)
->
ident
,
kind
:
str
)
{
let
ch
=
checker
(
e
,
kind
);
for
elt
:
T
in
elts
{
add_name
(
ch
,
sp
,
id
(
elt
));
}
...
...
src/comp/middle/trans.rs
浏览文件 @
5e13d19c
...
...
@@ -3233,8 +3233,8 @@ fn invoke_full(bcx: @block_ctxt, llfn: ValueRef, llargs: [ValueRef],
fn
invoke_
(
bcx
:
@
block_ctxt
,
llfn
:
ValueRef
,
llargs
:
[
ValueRef
],
to_zero
:
[{
v
:
ValueRef
,
t
:
ty
::
t
}],
to_revoke
:
[{
v
:
ValueRef
,
t
:
ty
::
t
}],
invoker
:
block
(
@
block_ctxt
,
ValueRef
,
[
ValueRef
],
BasicBlockRef
,
BasicBlockRef
))
->
@
block_ctxt
{
invoker
:
fn
(
@
block_ctxt
,
ValueRef
,
[
ValueRef
],
BasicBlockRef
,
BasicBlockRef
))
->
@
block_ctxt
{
// FIXME: May be worth turning this into a plain call when there are no
// cleanups to run
if
bcx
.unreachable
{
ret
bcx
;
}
...
...
@@ -4106,7 +4106,7 @@ fn trans_fn_cleanups(fcx: @fn_ctxt, cx: @block_ctxt) {
}
}
fn
block_locals
(
b
:
ast
::
blk
,
it
:
block
(
@
ast
::
local
))
{
fn
block_locals
(
b
:
ast
::
blk
,
it
:
fn
(
@
ast
::
local
))
{
for
s
:
@
ast
::
stmt
in
b
.node.stmts
{
alt
s
.node
{
ast
::
stmt_decl
(
d
,
_
)
{
...
...
@@ -4423,7 +4423,7 @@ enum self_arg { impl_self(ty::t), no_self, }
fn
trans_closure
(
cx
:
@
local_ctxt
,
sp
:
span
,
decl
:
ast
::
fn_decl
,
body
:
ast
::
blk
,
llfndecl
:
ValueRef
,
ty_self
:
self_arg
,
ty_params
:
[
ast
::
ty_param
],
id
:
ast
::
node_id
,
maybe_load_env
:
block
(
@
fn_ctxt
))
{
id
:
ast
::
node_id
,
maybe_load_env
:
fn
(
@
fn_ctxt
))
{
set_uwtable
(
llfndecl
);
// Set up arguments to the function.
...
...
src/comp/middle/trans_closure.rs
浏览文件 @
5e13d19c
...
...
@@ -57,7 +57,7 @@
// closure is allocated in the task heap and is reference counted.
// For a block, the closure is allocated on the stack. Note that in
// all cases we allocate space for a ref count just to make our lives
// easier when upcasting to
block
(T)->U, in the shape code, and so
// easier when upcasting to
fn
(T)->U, in the shape code, and so
// forth.
//
// ## Opaque Closures ##
...
...
@@ -637,7 +637,7 @@ fn trans_bind_1(cx: @block_ctxt, outgoing_fty: ty::t,
fn
make_null_test
(
in_bcx
:
@
block_ctxt
,
ptr
:
ValueRef
,
blk
:
block
(
@
block_ctxt
)
->
@
block_ctxt
)
blk
:
fn
(
@
block_ctxt
)
->
@
block_ctxt
)
->
@
block_ctxt
{
let
not_null_bcx
=
new_sub_block_ctxt
(
in_bcx
,
"not null"
);
let
next_bcx
=
new_sub_block_ctxt
(
in_bcx
,
"next"
);
...
...
src/comp/middle/trans_impl.rs
浏览文件 @
5e13d19c
...
...
@@ -157,7 +157,7 @@ fn trans_vtable(ccx: @crate_ctxt, id: ast::node_id, name: str,
}
fn
trans_wrapper
(
ccx
:
@
crate_ctxt
,
pt
:
[
ast
::
ident
],
llfty
:
TypeRef
,
fill
:
block
(
ValueRef
,
@
block_ctxt
)
->
@
block_ctxt
)
fill
:
fn
(
ValueRef
,
@
block_ctxt
)
->
@
block_ctxt
)
->
ValueRef
{
let
lcx
=
@
{
path
:
pt
,
module_path
:
[],
ccx
:
ccx
};
let
name
=
link
::
mangle_internal_name_by_path
(
ccx
,
pt
);
...
...
src/comp/middle/trans_vec.rs
浏览文件 @
5e13d19c
...
...
@@ -258,7 +258,7 @@ fn trans_add(bcx: @block_ctxt, vec_ty: ty::t, lhs: ValueRef,
type
val_and_ty_fn
=
fn
@
(
@
block_ctxt
,
ValueRef
,
ty
::
t
)
->
result
;
type
iter_vec_block
=
block
(
@
block_ctxt
,
ValueRef
,
ty
::
t
)
->
@
block_ctxt
;
type
iter_vec_block
=
fn
(
@
block_ctxt
,
ValueRef
,
ty
::
t
)
->
@
block_ctxt
;
fn
iter_vec_raw
(
bcx
:
@
block_ctxt
,
vptr
:
ValueRef
,
vec_ty
:
ty
::
t
,
fill
:
ValueRef
,
f
:
iter_vec_block
)
->
@
block_ctxt
{
...
...
src/comp/middle/tstate/auxiliary.rs
浏览文件 @
5e13d19c
...
...
@@ -968,7 +968,7 @@ fn non_init_constraint_mentions(_fcx: fn_ctxt, c: norm_constraint, v: node_id)
}
fn
args_mention
<
T
>
(
args
:
[
@
constr_arg_use
],
q
:
block
([
T
],
node_id
)
->
bool
,
q
:
fn
([
T
],
node_id
)
->
bool
,
s
:
[
T
])
->
bool
{
/*
FIXME
...
...
src/comp/middle/ty.rs
浏览文件 @
5e13d19c
...
...
@@ -1083,7 +1083,7 @@ fn type_is_native(cx: ctxt, ty: t) -> bool {
alt
struct
(
cx
,
ty
)
{
ty_native
(
_
)
{
ret
true
;
}
_
{
ret
false
;
}
}
}
fn
type_structurally_contains
(
cx
:
ctxt
,
ty
:
t
,
test
:
block
(
sty
)
->
bool
)
->
fn
type_structurally_contains
(
cx
:
ctxt
,
ty
:
t
,
test
:
fn
(
sty
)
->
bool
)
->
bool
{
let
sty
=
struct
(
cx
,
ty
);
if
test
(
sty
)
{
ret
true
;
}
...
...
@@ -1420,7 +1420,7 @@ fn hash_fn(id: uint, args: [arg], rty: t) -> uint {
fn
hash_raw_ty
(
&&
rt
:
@
raw_t
)
->
uint
{
ret
rt
.hash
;
}
fn
arg_eq
<
T
>
(
eq
:
block
(
T
,
T
)
->
bool
,
fn
arg_eq
<
T
>
(
eq
:
fn
(
T
,
T
)
->
bool
,
a
:
@
sp_constr_arg
<
T
>
,
b
:
@
sp_constr_arg
<
T
>
)
->
bool
{
...
...
@@ -1439,7 +1439,7 @@ fn arg_eq<T>(eq: block(T, T) -> bool,
}
}
fn
args_eq
<
T
>
(
eq
:
block
(
T
,
T
)
->
bool
,
fn
args_eq
<
T
>
(
eq
:
fn
(
T
,
T
)
->
bool
,
a
:
[
@
sp_constr_arg
<
T
>
],
b
:
[
@
sp_constr_arg
<
T
>
])
->
bool
{
let
i
:
uint
=
0u
;
...
...
@@ -1930,7 +1930,6 @@ fn unify_fn_proto(e_proto: ast::proto, a_proto: ast::proto,
fn
sub_proto
(
p_sub
:
ast
::
proto
,
p_sup
:
ast
::
proto
)
->
bool
{
ret
alt
(
p_sub
,
p_sup
)
{
(
_
,
ast
::
proto_any
)
{
true
}
(
_
,
ast
::
proto_block
)
{
true
}
/* NDM temporary */
(
ast
::
proto_bare
,
_
)
{
true
}
// Equal prototypes are always subprotos:
...
...
@@ -2083,7 +2082,7 @@ fn variance_transform(a: variance, b: variance) -> variance {
}
fn
unify_tps
(
cx
:
@
ctxt
,
expected_tps
:
[
t
],
actual_tps
:
[
t
],
variance
:
variance
,
finish
:
block
([
t
])
->
result
)
->
result
{
variance
:
variance
,
finish
:
fn
([
t
])
->
result
)
->
result
{
let
result_tps
=
[],
i
=
0u
;
for
exp
in
expected_tps
{
let
act
=
actual_tps
[
i
];
...
...
src/comp/syntax/ext/simplext.rs
浏览文件 @
5e13d19c
...
...
@@ -241,7 +241,7 @@ fn follow_for_trans(cx: ext_ctxt, mmaybe: option::t<arb_depth<matchable>>,
}
/* helper for transcribe_exprs: what vars from `b` occur in `e`? */
fn
free_vars
(
b
:
bindings
,
e
:
@
expr
,
it
:
block
(
ident
))
{
fn
free_vars
(
b
:
bindings
,
e
:
@
expr
,
it
:
fn
(
ident
))
{
let
idents
:
hashmap
<
ident
,
()
>
=
new_str_hash
::
<
()
>
();
fn
mark_ident
(
&&
i
:
ident
,
_
fld
:
ast_fold
,
b
:
bindings
,
idents
:
hashmap
<
ident
,
()
>
)
->
ident
{
...
...
@@ -536,7 +536,7 @@ fn block_to_ident(blk: blk_) -> option::t<ident> {
fn
p_t_s_r_mac
(
cx
:
ext_ctxt
,
mac
:
ast
::
mac
,
s
:
selector
,
b
:
binders
)
{
fn
select_pt_1
(
cx
:
ext_ctxt
,
m
:
matchable
,
fn_m
:
block
(
ast
::
mac
)
->
match_result
)
->
match_result
{
fn_m
:
fn
(
ast
::
mac
)
->
match_result
)
->
match_result
{
ret
alt
m
{
match_expr
(
e
)
{
alt
e
.node
{
expr_mac
(
mac
)
{
fn_m
(
mac
)
}
_
{
none
}
}
...
...
src/comp/syntax/parse/parser.rs
浏览文件 @
5e13d19c
...
...
@@ -149,7 +149,7 @@ fn bad_expr_word_table() -> hashmap<str, ()> {
for
word
in
[
"mod"
,
"if"
,
"else"
,
"while"
,
"do"
,
"alt"
,
"for"
,
"break"
,
"cont"
,
"ret"
,
"be"
,
"fail"
,
"type"
,
"resource"
,
"check"
,
"assert"
,
"claim"
,
"native"
,
"fn"
,
"pure"
,
"unsafe"
,
"
block"
,
"
import"
,
"export"
,
"let"
,
"const"
,
"unsafe"
,
"import"
,
"export"
,
"let"
,
"const"
,
"log"
,
"copy"
,
"sendfn"
,
"impl"
,
"iface"
,
"enum"
]
{
words
.insert
(
word
,
());
}
...
...
@@ -366,7 +366,7 @@ fn parse_constr_in_type(p: parser) -> @ast::ty_constr {
}
fn
parse_constrs
<
T
:
copy
>
(
pser
:
block
(
parser
)
->
@
ast
::
constr_general
<
T
>
,
fn
parse_constrs
<
T
:
copy
>
(
pser
:
fn
(
parser
)
->
@
ast
::
constr_general
<
T
>
,
p
:
parser
)
->
[
@
ast
::
constr_general
<
T
>
]
{
let
constrs
:
[
@
ast
::
constr_general
<
T
>
]
=
[];
...
...
@@ -504,9 +504,6 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
_
{
/* fallthrough */
}
}
t
=
parse_ty_fn
(
proto
,
p
);
}
else
if
eat_word
(
p
,
"block"
)
{
//p.warn("block is deprecated, use fn& or fn");
t
=
parse_ty_fn
(
ast
::
proto_block
,
p
);
}
else
if
eat_word
(
p
,
"native"
)
{
expect_word
(
p
,
"fn"
);
t
=
parse_ty_fn
(
ast
::
proto_bare
,
p
);
...
...
@@ -545,7 +542,7 @@ fn parse_fn_block_arg(p: parser) -> ast::arg {
}
fn
parse_seq_to_before_gt
<
T
:
copy
>
(
sep
:
option
::
t
<
token
::
token
>
,
f
:
block
(
parser
)
->
T
,
f
:
fn
(
parser
)
->
T
,
p
:
parser
)
->
[
T
]
{
let
first
=
true
;
let
v
=
[];
...
...
@@ -562,7 +559,7 @@ fn parse_seq_to_before_gt<T: copy>(sep: option::t<token::token>,
}
fn
parse_seq_to_gt
<
T
:
copy
>
(
sep
:
option
::
t
<
token
::
token
>
,
f
:
block
(
parser
)
->
T
,
p
:
parser
)
->
[
T
]
{
f
:
fn
(
parser
)
->
T
,
p
:
parser
)
->
[
T
]
{
let
v
=
parse_seq_to_before_gt
(
sep
,
f
,
p
);
expect_gt
(
p
);
...
...
@@ -570,7 +567,7 @@ fn parse_seq_to_gt<T: copy>(sep: option::t<token::token>,
}
fn
parse_seq_lt_gt
<
T
:
copy
>
(
sep
:
option
::
t
<
token
::
token
>
,
f
:
block
(
parser
)
->
T
,
f
:
fn
(
parser
)
->
T
,
p
:
parser
)
->
spanned
<
[
T
]
>
{
let
lo
=
p
.span.lo
;
expect
(
p
,
token
::
LT
);
...
...
@@ -581,7 +578,7 @@ fn parse_seq_lt_gt<T: copy>(sep: option::t<token::token>,
}
fn
parse_seq_to_end
<
T
:
copy
>
(
ket
:
token
::
token
,
sep
:
seq_sep
,
f
:
block
(
parser
)
->
T
,
p
:
parser
)
->
[
T
]
{
f
:
fn
(
parser
)
->
T
,
p
:
parser
)
->
[
T
]
{
let
val
=
parse_seq_to_before_end
(
ket
,
sep
,
f
,
p
);
p
.bump
();
ret
val
;
...
...
@@ -604,7 +601,7 @@ fn seq_sep_none() -> seq_sep {
fn
parse_seq_to_before_end
<
T
:
copy
>
(
ket
:
token
::
token
,
sep
:
seq_sep
,
f
:
block
(
parser
)
->
T
,
p
:
parser
)
->
[
T
]
{
f
:
fn
(
parser
)
->
T
,
p
:
parser
)
->
[
T
]
{
let
first
:
bool
=
true
;
let
v
:
[
T
]
=
[];
while
p
.token
!=
ket
{
...
...
@@ -620,7 +617,7 @@ fn parse_seq_to_before_end<T: copy>(ket: token::token,
fn
parse_seq
<
T
:
copy
>
(
bra
:
token
::
token
,
ket
:
token
::
token
,
sep
:
seq_sep
,
f
:
block
(
parser
)
->
T
,
sep
:
seq_sep
,
f
:
fn
(
parser
)
->
T
,
p
:
parser
)
->
spanned
<
[
T
]
>
{
let
lo
=
p
.span.lo
;
expect
(
p
,
bra
);
...
...
@@ -813,9 +810,6 @@ fn parse_bottom_expr(p: parser) -> pexpr {
_
{
/* fallthrough */
}
}
ret
pexpr
(
parse_fn_expr
(
p
,
proto
));
}
else
if
eat_word
(
p
,
"block"
)
{
p
.warn
(
"block is deprecated, use fn& or fn"
);
ret
pexpr
(
parse_fn_expr
(
p
,
ast
::
proto_block
));
}
else
if
eat_word
(
p
,
"unchecked"
)
{
ret
pexpr
(
parse_block_expr
(
p
,
lo
,
ast
::
unchecked_blk
));
}
else
if
eat_word
(
p
,
"unsafe"
)
{
...
...
src/comp/syntax/print/pprust.rs
浏览文件 @
5e13d19c
...
...
@@ -210,7 +210,7 @@ fn synth_comment(s: ps, text: str) {
word
(
s
.s
,
"*/"
);
}
fn
commasep
<
IN
>
(
s
:
ps
,
b
:
breaks
,
elts
:
[
IN
],
op
:
block
(
ps
,
IN
))
{
fn
commasep
<
IN
>
(
s
:
ps
,
b
:
breaks
,
elts
:
[
IN
],
op
:
fn
(
ps
,
IN
))
{
box
(
s
,
0u
,
b
);
let
first
=
true
;
for
elt
:
IN
in
elts
{
...
...
@@ -221,8 +221,8 @@ fn commasep<IN>(s: ps, b: breaks, elts: [IN], op: block(ps, IN)) {
}
fn
commasep_cmnt
<
IN
>
(
s
:
ps
,
b
:
breaks
,
elts
:
[
IN
],
op
:
block
(
ps
,
IN
),
get_span
:
block
(
IN
)
->
codemap
::
span
)
{
fn
commasep_cmnt
<
IN
>
(
s
:
ps
,
b
:
breaks
,
elts
:
[
IN
],
op
:
fn
(
ps
,
IN
),
get_span
:
fn
(
IN
)
->
codemap
::
span
)
{
box
(
s
,
0u
,
b
);
let
len
=
vec
::
len
::
<
IN
>
(
elts
);
let
i
=
0u
;
...
...
src/comp/util/filesearch.rs
浏览文件 @
5e13d19c
...
...
@@ -18,7 +18,7 @@
export
get_cargo_root
;
export
libdir
;
type
pick
<
T
>
=
block
(
path
:
fs
::
path
)
->
option
::
t
<
T
>
;
type
pick
<
T
>
=
fn
(
path
:
fs
::
path
)
->
option
::
t
<
T
>
;
fn
pick_file
(
file
:
fs
::
path
,
path
:
fs
::
path
)
->
option
::
t
<
fs
::
path
>
{
if
fs
::
basename
(
path
)
==
file
{
option
::
some
(
path
)
}
...
...
src/compiletest/header.rs
浏览文件 @
5e13d19c
...
...
@@ -63,7 +63,7 @@ fn xfail_target() -> str {
}
}
fn
iter_header
(
testfile
:
str
,
it
:
block
(
str
))
{
fn
iter_header
(
testfile
:
str
,
it
:
fn
(
str
))
{
let
rdr
=
result
::
get
(
io
::
file_reader
(
testfile
));
while
!
rdr
.eof
()
{
let
ln
=
rdr
.read_line
();
...
...
src/fuzzer/fuzzer.rs
浏览文件 @
5e13d19c
...
...
@@ -215,7 +215,7 @@ fn fold_ty_rep(j_: @mutable uint, i_: uint, newty_: ast::ty_,
*
crate2
}
fn
under
(
n
:
uint
,
it
:
block
(
uint
))
{
fn
under
(
n
:
uint
,
it
:
fn
(
uint
))
{
let
i
:
uint
=
0u
;
while
i
<
n
{
it
(
i
);
i
+=
1u
;
}
}
...
...
src/libcore/bool.rs
浏览文件 @
5e13d19c
...
...
@@ -75,7 +75,7 @@
brief
=
"Iterates over all truth values by passing them to `blk`
\
in an unspecified order"
)]
fn
all_values
(
blk
:
block
(
v
:
t
))
{
fn
all_values
(
blk
:
fn
(
v
:
t
))
{
blk
(
true
);
blk
(
false
);
}
...
...
src/libcore/either.rs
浏览文件 @
5e13d19c
...
...
@@ -29,7 +29,7 @@ enum t<T, U> {
the result is returned.
*/
fn
either
<
T
,
U
,
V
>
(
f_left
:
block
(
T
)
->
V
,
f_right
:
block
(
U
)
->
V
,
value
:
t
<
T
,
U
>
)
->
V
>
(
f_left
:
fn
(
T
)
->
V
,
f_right
:
fn
(
U
)
->
V
,
value
:
t
<
T
,
U
>
)
->
V
{
alt
value
{
left
(
l
)
{
f_left
(
l
)
}
right
(
r
)
{
f_right
(
r
)
}
}
}
...
...
src/libcore/int.rs
浏览文件 @
5e13d19c
...
...
@@ -84,7 +84,7 @@
Iterate over the range [`lo`..`hi`)
*/
fn
range
(
lo
:
int
,
hi
:
int
,
it
:
block
(
int
))
{
fn
range
(
lo
:
int
,
hi
:
int
,
it
:
fn
(
int
))
{
let
i
=
lo
;
while
i
<
hi
{
it
(
i
);
i
+=
1
;
}
}
...
...
src/libcore/option.rs
浏览文件 @
5e13d19c
...
...
@@ -36,7 +36,7 @@ enum t<T> {
/*
*/
fn
map
<
T
,
U
:
copy
>
(
opt
:
t
<
T
>
,
f
:
block
(
T
)
->
U
)
->
t
<
U
>
{
fn
map
<
T
,
U
:
copy
>
(
opt
:
t
<
T
>
,
f
:
fn
(
T
)
->
U
)
->
t
<
U
>
{
alt
opt
{
some
(
x
)
{
some
(
f
(
x
))
}
none
{
none
}
}
}
...
...
@@ -70,7 +70,7 @@ fn map<T, U: copy>(opt: t<T>, f: block(T) -> U) -> t<U> {
Applies a function to the contained value or returns a default
*/
fn
maybe
<
T
,
U
:
copy
>
(
def
:
U
,
opt
:
t
<
T
>
,
f
:
block
(
T
)
->
U
)
->
U
{
fn
maybe
<
T
,
U
:
copy
>
(
def
:
U
,
opt
:
t
<
T
>
,
f
:
fn
(
T
)
->
U
)
->
U
{
alt
opt
{
none
{
def
}
some
(
t
)
{
f
(
t
)
}
}
}
...
...
@@ -80,7 +80,7 @@ fn maybe<T, U: copy>(def: U, opt: t<T>, f: block(T) -> U) -> U {
Performs an operation on the contained value or does nothing
*/
fn
may
<
T
>
(
opt
:
t
<
T
>
,
f
:
block
(
T
))
{
fn
may
<
T
>
(
opt
:
t
<
T
>
,
f
:
fn
(
T
))
{
alt
opt
{
none
{
/* nothing */
}
some
(
t
)
{
f
(
t
);
}
}
}
...
...
src/libcore/result.rs
浏览文件 @
5e13d19c
...
...
@@ -110,7 +110,7 @@ fn get_err<T, U: copy>(res: t<T, U>) -> U {
> })
*/
fn
chain
<
T
,
U
:
copy
,
V
:
copy
>
(
res
:
t
<
T
,
V
>
,
op
:
block
(
T
)
->
t
<
U
,
V
>
)
fn
chain
<
T
,
U
:
copy
,
V
:
copy
>
(
res
:
t
<
T
,
V
>
,
op
:
fn
(
T
)
->
t
<
U
,
V
>
)
->
t
<
U
,
V
>
{
alt
res
{
ok
(
t
)
{
op
(
t
)
}
...
...
src/libcore/str.rs
浏览文件 @
5e13d19c
...
...
@@ -347,7 +347,7 @@ fn char_range_at(s: str, i: uint) -> {ch: char, next: uint} {
Iterate over the characters in a string
*/
fn
iter_chars
(
s
:
str
,
it
:
block
(
char
))
{
fn
iter_chars
(
s
:
str
,
it
:
fn
(
char
))
{
let
pos
=
0u
,
len
=
byte_len
(
s
);
while
(
pos
<
len
)
{
let
{
ch
,
next
}
=
char_range_at
(
s
,
pos
);
...
...
@@ -371,7 +371,7 @@ fn iter_chars(s: str, it: block(char)) {
`true` If execution proceeded correctly, `false` if it was interrupted,
that is if `it` returned `false` at any point.
*/
fn
loop_chars
(
s
:
str
,
it
:
block
(
char
)
->
bool
)
->
bool
{
fn
loop_chars
(
s
:
str
,
it
:
fn
(
char
)
->
bool
)
->
bool
{
ret
loop_chars_sub
(
s
,
0u
,
byte_len
(
s
),
it
);
}
...
...
@@ -398,7 +398,7 @@ fn loop_chars(s: str, it: block(char) -> bool) -> bool{
represent valid positions inside `s`
*/
fn
loop_chars_sub
(
s
:
str
,
byte_offset
:
uint
,
byte_len
:
uint
,
it
:
block
(
char
)
->
bool
)
->
bool
{
it
:
fn
(
char
)
->
bool
)
->
bool
{
let
i
=
byte_offset
;
let
result
=
true
;
while
i
<
byte_len
{
...
...
@@ -1061,7 +1061,7 @@ unsafe fn buf(s: str) -> sbuf {
> let s = str::as_buf("PATH", { |path_buf| libc::getenv(path_buf) });
*/
fn
as_buf
<
T
>
(
s
:
str
,
f
:
block
(
sbuf
)
->
T
)
->
T
unsafe
{
fn
as_buf
<
T
>
(
s
:
str
,
f
:
fn
(
sbuf
)
->
T
)
->
T
unsafe
{
let
buf
=
buf
(
s
);
f
(
buf
)
}
...
...
src/libcore/u32.rs
浏览文件 @
5e13d19c
...
...
@@ -54,7 +54,7 @@
Iterate over the range [`lo`..`hi`)
*/
fn
range
(
lo
:
u32
,
hi
:
u32
,
it
:
block
(
u32
))
{
fn
range
(
lo
:
u32
,
hi
:
u32
,
it
:
fn
(
u32
))
{
let
i
=
lo
;
while
i
<
hi
{
it
(
i
);
i
+=
1u32
;
}
}
...
...
src/libcore/u64.rs
浏览文件 @
5e13d19c
...
...
@@ -54,7 +54,7 @@
Iterate over the range [`lo`..`hi`)
*/
fn
range
(
lo
:
u64
,
hi
:
u64
,
it
:
block
(
u64
))
{
fn
range
(
lo
:
u64
,
hi
:
u64
,
it
:
fn
(
u64
))
{
let
i
=
lo
;
while
i
<
hi
{
it
(
i
);
i
+=
1u64
;
}
}
...
...
src/libcore/u8.rs
浏览文件 @
5e13d19c
...
...
@@ -54,7 +54,7 @@
Iterate over the range [`lo`..`hi`)
*/
fn
range
(
lo
:
u8
,
hi
:
u8
,
it
:
block
(
u8
))
{
fn
range
(
lo
:
u8
,
hi
:
u8
,
it
:
fn
(
u8
))
{
let
i
=
lo
;
while
i
<
hi
{
it
(
i
);
i
+=
1u8
;
}
}
...
...
src/libcore/uint.rs
浏览文件 @
5e13d19c
...
...
@@ -115,7 +115,7 @@
Iterate over the range [`lo`..`hi`)
*/
fn
range
(
lo
:
uint
,
hi
:
uint
,
it
:
block
(
uint
))
{
fn
range
(
lo
:
uint
,
hi
:
uint
,
it
:
fn
(
uint
))
{
let
i
=
lo
;
while
i
<
hi
{
it
(
i
);
i
+=
1u
;
}
}
...
...
@@ -136,7 +136,7 @@ fn range(lo: uint, hi: uint, it: block(uint)) {
`true` If execution proceeded correctly, `false` if it was interrupted,
that is if `it` returned `false` at any point.
*/
fn
loop
(
lo
:
uint
,
hi
:
uint
,
it
:
block
(
uint
)
->
bool
)
->
bool
{
fn
loop
(
lo
:
uint
,
hi
:
uint
,
it
:
fn
(
uint
)
->
bool
)
->
bool
{
let
i
=
lo
;
while
i
<
hi
{
if
(
!
it
(
i
))
{
ret
false
;
}
...
...
src/libcore/vec.rs
浏览文件 @
5e13d19c
...
...
@@ -26,7 +26,7 @@ fn vec_from_buf_shared<T>(t: *sys::type_desc,
A function used to initialize the elements of a vector.
*/
type
init_op
<
T
>
=
block
(
uint
)
->
T
;
type
init_op
<
T
>
=
fn
(
uint
)
->
T
;
/*
...
...
@@ -402,7 +402,7 @@ fn grow_set<T: copy>(&v: [mutable T], index: uint, initval: T, val: T) {
Apply a function to each element of a vector and return the results
*/
fn
map
<
T
,
U
>
(
v
:
[
T
],
f
:
block
(
T
)
->
U
)
->
[
U
]
{
fn
map
<
T
,
U
>
(
v
:
[
T
],
f
:
fn
(
T
)
->
U
)
->
[
U
]
{
let
result
=
[];
reserve
(
result
,
len
(
v
));
for
elem
:
T
in
v
{
result
+=
[
f
(
elem
)];
}
...
...
@@ -414,7 +414,7 @@ fn map<T, U>(v: [T], f: block(T) -> U) -> [U] {
Apply a function to each element of a mutable vector and return the results
*/
fn
map_mut
<
T
:
copy
,
U
>
(
v
:
[
const
T
],
f
:
block
(
T
)
->
U
)
->
[
U
]
{
fn
map_mut
<
T
:
copy
,
U
>
(
v
:
[
const
T
],
f
:
fn
(
T
)
->
U
)
->
[
U
]
{
let
result
=
[];
reserve
(
result
,
len
(
v
));
for
elem
:
T
in
v
{
...
...
@@ -429,7 +429,7 @@ fn map_mut<T: copy, U>(v: [const T], f: block(T) -> U) -> [U] {
Apply a function to each pair of elements and return the results
*/
fn
map2
<
T
:
copy
,
U
:
copy
,
V
>
(
v0
:
[
T
],
v1
:
[
U
],
f
:
block
(
T
,
U
)
->
V
)
->
[
V
]
{
fn
map2
<
T
:
copy
,
U
:
copy
,
V
>
(
v0
:
[
T
],
v1
:
[
U
],
f
:
fn
(
T
,
U
)
->
V
)
->
[
V
]
{
let
v0_len
=
len
(
v0
);
if
v0_len
!=
len
(
v1
)
{
fail
;
}
let
u
:
[
V
]
=
[];
...
...
@@ -446,7 +446,7 @@ fn map2<T: copy, U: copy, V>(v0: [T], v1: [U], f: block(T, U) -> V) -> [V] {
If function `f` returns `none` then that element is excluded from
the resulting vector.
*/
fn
filter_map
<
T
:
copy
,
U
:
copy
>
(
v
:
[
const
T
],
f
:
block
(
T
)
->
option
::
t
<
U
>
)
fn
filter_map
<
T
:
copy
,
U
:
copy
>
(
v
:
[
const
T
],
f
:
fn
(
T
)
->
option
::
t
<
U
>
)
->
[
U
]
{
let
result
=
[];
for
elem
:
T
in
v
{
...
...
@@ -467,7 +467,7 @@ fn filter_map<T: copy, U: copy>(v: [const T], f: block(T) -> option::t<U>)
Apply function `f` to each element of `v` and return a vector containing
only those elements for which `f` returned true.
*/
fn
filter
<
T
:
copy
>
(
v
:
[
T
],
f
:
block
(
T
)
->
bool
)
->
[
T
]
{
fn
filter
<
T
:
copy
>
(
v
:
[
T
],
f
:
fn
(
T
)
->
bool
)
->
[
T
]
{
let
result
=
[];
for
elem
:
T
in
v
{
if
f
(
elem
)
{
result
+=
[
elem
];
}
...
...
@@ -492,7 +492,7 @@ fn concat<T: copy>(v: [const [const T]]) -> [T] {
Reduce a vector from left to right
*/
fn
foldl
<
T
:
copy
,
U
>
(
z
:
T
,
v
:
[
const
U
],
p
:
block
(
T
,
U
)
->
T
)
->
T
{
fn
foldl
<
T
:
copy
,
U
>
(
z
:
T
,
v
:
[
const
U
],
p
:
fn
(
T
,
U
)
->
T
)
->
T
{
let
accum
=
z
;
iter
(
v
)
{
|
elt
|
accum
=
p
(
accum
,
elt
);
...
...
@@ -505,7 +505,7 @@ fn foldl<T: copy, U>(z: T, v: [const U], p: block(T, U) -> T) -> T {
Reduce a vector from right to left
*/
fn
foldr
<
T
,
U
:
copy
>
(
v
:
[
const
T
],
z
:
U
,
p
:
block
(
T
,
U
)
->
U
)
->
U
{
fn
foldr
<
T
,
U
:
copy
>
(
v
:
[
const
T
],
z
:
U
,
p
:
fn
(
T
,
U
)
->
U
)
->
U
{
let
accum
=
z
;
riter
(
v
)
{
|
elt
|
accum
=
p
(
elt
,
accum
);
...
...
@@ -520,7 +520,7 @@ fn foldr<T, U: copy>(v: [const T], z: U, p: block(T, U) -> U) -> U {
If the vector contains no elements then false is returned.
*/
fn
any
<
T
>
(
v
:
[
T
],
f
:
block
(
T
)
->
bool
)
->
bool
{
fn
any
<
T
>
(
v
:
[
T
],
f
:
fn
(
T
)
->
bool
)
->
bool
{
for
elem
:
T
in
v
{
if
f
(
elem
)
{
ret
true
;
}
}
ret
false
;
}
...
...
@@ -532,7 +532,7 @@ fn any<T>(v: [T], f: block(T) -> bool) -> bool {
If the vectors contains no elements then false is returned.
*/
fn
any2
<
T
,
U
>
(
v0
:
[
T
],
v1
:
[
U
],
f
:
block
(
T
,
U
)
->
bool
)
->
bool
{
fn
any2
<
T
,
U
>
(
v0
:
[
T
],
v1
:
[
U
],
f
:
fn
(
T
,
U
)
->
bool
)
->
bool
{
let
v0_len
=
len
(
v0
);
let
v1_len
=
len
(
v1
);
let
i
=
0u
;
...
...
@@ -550,7 +550,7 @@ fn any2<T, U>(v0: [T], v1: [U], f: block(T, U) -> bool) -> bool {
If the vector contains no elements then true is returned.
*/
fn
all
<
T
>
(
v
:
[
T
],
f
:
block
(
T
)
->
bool
)
->
bool
{
fn
all
<
T
>
(
v
:
[
T
],
f
:
fn
(
T
)
->
bool
)
->
bool
{
for
elem
:
T
in
v
{
if
!
f
(
elem
)
{
ret
false
;
}
}
ret
true
;
}
...
...
@@ -562,7 +562,7 @@ fn all<T>(v: [T], f: block(T) -> bool) -> bool {
If the vectors are not the same size then false is returned.
*/
fn
all2
<
T
,
U
>
(
v0
:
[
T
],
v1
:
[
U
],
f
:
block
(
T
,
U
)
->
bool
)
->
bool
{
fn
all2
<
T
,
U
>
(
v0
:
[
T
],
v1
:
[
U
],
f
:
fn
(
T
,
U
)
->
bool
)
->
bool
{
let
v0_len
=
len
(
v0
);
if
v0_len
!=
len
(
v1
)
{
ret
false
;
}
let
i
=
0u
;
...
...
@@ -600,7 +600,7 @@ fn count<T>(x: T, v: [const T]) -> uint {
When function `f` returns true then an option containing the element
is returned. If `f` matches no elements then none is returned.
*/
fn
find
<
T
:
copy
>
(
v
:
[
T
],
f
:
block
(
T
)
->
bool
)
->
option
::
t
<
T
>
{
fn
find
<
T
:
copy
>
(
v
:
[
T
],
f
:
fn
(
T
)
->
bool
)
->
option
::
t
<
T
>
{
for
elt
:
T
in
v
{
if
f
(
elt
)
{
ret
some
(
elt
);
}
}
ret
none
;
}
...
...
@@ -626,7 +626,7 @@ fn position<T>(x: T, v: [T]) -> option::t<uint> {
Find the first index for which the value matches some predicate
*/
fn
position_pred
<
T
>
(
v
:
[
T
],
f
:
block
(
T
)
->
bool
)
->
option
::
t
<
uint
>
{
fn
position_pred
<
T
>
(
v
:
[
T
],
f
:
fn
(
T
)
->
bool
)
->
option
::
t
<
uint
>
{
let
i
:
uint
=
0u
;
while
i
<
len
(
v
)
{
if
f
(
v
[
i
])
{
ret
some
::
<
uint
>
(
i
);
}
i
+=
1u
;
}
ret
none
;
...
...
@@ -747,7 +747,7 @@ fn enum_uints(start: uint, end: uint) : uint::le(start, end) -> [uint] {
element's value.
*/
fn
iter
<
T
>
(
v
:
[
const
T
],
f
:
block
(
T
))
{
fn
iter
<
T
>
(
v
:
[
const
T
],
f
:
fn
(
T
))
{
iteri
(
v
)
{
|
_
i
,
v
|
f
(
v
)
}
}
...
...
@@ -757,7 +757,7 @@ fn iter<T>(v: [const T], f: block(T)) {
Iterates over two vectors in parallel
*/
fn
iter2
<
U
,
T
>
(
v
:
[
U
],
v2
:
[
T
],
f
:
block
(
U
,
T
))
{
fn
iter2
<
U
,
T
>
(
v
:
[
U
],
v2
:
[
T
],
f
:
fn
(
U
,
T
))
{
let
i
=
0
;
for
elt
in
v
{
f
(
elt
,
v2
[
i
]);
i
+=
1
;
}
}
...
...
@@ -770,7 +770,7 @@ fn iter2<U, T>(v: [U], v2: [T], f: block(U, T)) {
Iterates over vector `v` and, for each element, calls function `f` with the
element's value and index.
*/
fn
iteri
<
T
>
(
v
:
[
const
T
],
f
:
block
(
uint
,
T
))
{
fn
iteri
<
T
>
(
v
:
[
const
T
],
f
:
fn
(
uint
,
T
))
{
let
i
=
0u
,
l
=
len
(
v
);
while
i
<
l
{
f
(
i
,
v
[
i
]);
i
+=
1u
;
}
}
...
...
@@ -784,7 +784,7 @@ fn iteri<T>(v: [const T], f: block(uint, T)) {
element's value.
*/
fn
riter
<
T
>
(
v
:
[
const
T
],
f
:
block
(
T
))
{
fn
riter
<
T
>
(
v
:
[
const
T
],
f
:
fn
(
T
))
{
riteri
(
v
)
{
|
_
i
,
v
|
f
(
v
)
}
}
...
...
@@ -796,7 +796,7 @@ fn riter<T>(v: [const T], f: block(T)) {
Iterates over vector `v` and, for each element, calls function `f` with the
element's value and index.
*/
fn
riteri
<
T
>
(
v
:
[
const
T
],
f
:
block
(
uint
,
T
))
{
fn
riteri
<
T
>
(
v
:
[
const
T
],
f
:
fn
(
uint
,
T
))
{
let
i
=
len
(
v
);
while
0u
<
i
{
i
-=
1u
;
...
...
@@ -814,7 +814,7 @@ fn riteri<T>(v: [const T], f: block(uint, T)) {
The total number of permutations produced is `len(v)!`. If `v` contains
repeated elements, then some permutations are repeated.
*/
fn
permute
<
T
:
copy
>
(
v
:
[
const
T
],
put
:
block
([
T
]))
{
fn
permute
<
T
:
copy
>
(
v
:
[
const
T
],
put
:
fn
([
T
]))
{
let
ln
=
len
(
v
);
if
ln
==
0u
{
put
([]);
...
...
src/libstd/bitv.rs
浏览文件 @
5e13d19c
...
...
@@ -53,7 +53,7 @@ fn create(nbits: uint, init: bool) -> t {
ret
@
{
storage
:
storage
,
nbits
:
nbits
};
}
fn
process
(
v0
:
t
,
v1
:
t
,
op
:
block
(
uint
,
uint
)
->
uint
)
->
bool
{
fn
process
(
v0
:
t
,
v1
:
t
,
op
:
fn
(
uint
,
uint
)
->
uint
)
->
bool
{
let
len
=
vec
::
len
(
v1
.storage
);
assert
(
vec
::
len
(
v0
.storage
)
==
len
);
assert
(
v0
.nbits
==
v1
.nbits
);
...
...
src/libstd/ebml.rs
浏览文件 @
5e13d19c
...
...
@@ -73,7 +73,7 @@ fn get_doc(d: doc, tg: uint) -> doc {
}
}
fn
docs
(
d
:
doc
,
it
:
block
(
uint
,
doc
))
{
fn
docs
(
d
:
doc
,
it
:
fn
(
uint
,
doc
))
{
let
pos
=
d
.start
;
while
pos
<
d
.end
{
let
elt_tag
=
vint_at
(
*
d
.data
,
pos
);
...
...
@@ -83,7 +83,7 @@ fn docs(d: doc, it: block(uint, doc)) {
}
}
fn
tagged_docs
(
d
:
doc
,
tg
:
uint
,
it
:
block
(
doc
))
{
fn
tagged_docs
(
d
:
doc
,
tg
:
uint
,
it
:
fn
(
doc
))
{
let
pos
=
d
.start
;
while
pos
<
d
.end
{
let
elt_tag
=
vint_at
(
*
d
.data
,
pos
);
...
...
src/libstd/four.rs
浏览文件 @
5e13d19c
...
...
@@ -195,7 +195,7 @@
Iterates over all truth values by passing them to `blk`
in an unspecified order
*/
fn
all_values
(
blk
:
block
(
v
:
t
))
{
fn
all_values
(
blk
:
fn
(
v
:
t
))
{
blk
(
both
);
blk
(
four
::
true
);
blk
(
four
::
false
);
...
...
src/libstd/fun_treemap.rs
浏览文件 @
5e13d19c
...
...
@@ -84,7 +84,7 @@ fn find<K, V: copy>(m: treemap<K, V>, k: K) -> option<V> {
Visit all pairs in the map in order.
*/
fn
traverse
<
K
,
V
:
copy
>
(
m
:
treemap
<
K
,
V
>
,
f
:
block
(
K
,
V
))
{
fn
traverse
<
K
,
V
:
copy
>
(
m
:
treemap
<
K
,
V
>
,
f
:
fn
(
K
,
V
))
{
alt
*
m
{
empty
{
}
node
(
@
k
,
@
v
,
_
,
_
)
{
...
...
src/libstd/io.rs
浏览文件 @
5e13d19c
...
...
@@ -529,7 +529,7 @@ enum level {
// fsync file after executing blk
// FIXME find better way to create resources within lifetime of outer res
fn
FILE_res_sync
(
&&
file
:
FILE_res
,
opt_level
:
option
::
t
<
level
>
,
blk
:
block
(
&&
res
<
os
::
libc
::
FILE
>
))
{
blk
:
fn
(
&&
res
<
os
::
libc
::
FILE
>
))
{
blk
(
res
({
val
:
*
file
,
opt_level
:
opt_level
,
fsync_fn
:
fn
@
(
&&
file
:
os
::
libc
::
FILE
,
l
:
level
)
->
int
{
...
...
@@ -540,7 +540,7 @@ fn FILE_res_sync(&&file: FILE_res, opt_level: option::t<level>,
// fsync fd after executing blk
fn
fd_res_sync
(
&&
fd
:
fd_res
,
opt_level
:
option
::
t
<
level
>
,
blk
:
block
(
&&
res
<
fd_t
>
))
{
blk
:
fn
(
&&
res
<
fd_t
>
))
{
blk
(
res
({
val
:
*
fd
,
opt_level
:
opt_level
,
fsync_fn
:
fn
@
(
&&
fd
:
fd_t
,
l
:
level
)
->
int
{
...
...
@@ -553,7 +553,7 @@ fn fd_res_sync(&&fd: fd_res, opt_level: option::t<level>,
iface
t
{
fn
fsync
(
l
:
level
)
->
int
;
}
// Call o.fsync after executing blk
fn
obj_sync
(
&&
o
:
t
,
opt_level
:
option
::
t
<
level
>
,
blk
:
block
(
&&
res
<
t
>
))
{
fn
obj_sync
(
&&
o
:
t
,
opt_level
:
option
::
t
<
level
>
,
blk
:
fn
(
&&
res
<
t
>
))
{
blk
(
res
({
val
:
o
,
opt_level
:
opt_level
,
fsync_fn
:
fn
@
(
&&
o
:
t
,
l
:
level
)
->
int
{
ret
o
.fsync
(
l
);
}
...
...
src/libstd/list.rs
浏览文件 @
5e13d19c
...
...
@@ -46,7 +46,7 @@ fn from_vec<T: copy>(v: [const T]) -> list<T> {
z - The initial value
f - The function to apply
*/
fn
foldl
<
T
:
copy
,
U
>
(
ls
:
list
<
U
>
,
z
:
T
,
f
:
block
(
T
,
U
)
->
T
)
->
T
{
fn
foldl
<
T
:
copy
,
U
>
(
ls
:
list
<
U
>
,
z
:
T
,
f
:
fn
(
T
,
U
)
->
T
)
->
T
{
let
accum
:
T
=
z
;
iter
(
ls
)
{|
elt
|
accum
=
f
(
accum
,
elt
);}
accum
...
...
@@ -61,7 +61,7 @@ fn foldl<T: copy, U>(ls: list<U>, z: T, f: block(T, U) -> T) -> T {
When function `f` returns true then an option containing the element
is returned. If `f` matches no elements then none is returned.
*/
fn
find
<
T
:
copy
,
U
:
copy
>
(
ls
:
list
<
T
>
,
f
:
block
(
T
)
->
option
::
t
<
U
>
)
fn
find
<
T
:
copy
,
U
:
copy
>
(
ls
:
list
<
T
>
,
f
:
fn
(
T
)
->
option
::
t
<
U
>
)
->
option
::
t
<
U
>
{
let
ls
=
ls
;
while
true
{
...
...
@@ -164,7 +164,7 @@ fn len<T>(ls: list<T>) -> uint {
Iterate over a list
*/
fn
iter
<
T
>
(
l
:
list
<
T
>
,
f
:
block
(
T
))
{
fn
iter
<
T
>
(
l
:
list
<
T
>
,
f
:
fn
(
T
))
{
alt
l
{
cons
(
hd
,
tl
)
{
f
(
hd
);
...
...
src/libstd/map.rs
浏览文件 @
5e13d19c
...
...
@@ -88,17 +88,17 @@
Iterate over all the key/value pairs in the map
*/
fn
items
(
block
(
K
,
V
));
fn
items
(
fn
(
K
,
V
));
/*
Method: keys
Iterate over all the keys in the map
*/
fn
keys
(
block
(
K
));
fn
keys
(
fn
(
K
));
/*
Iterate over all the values in the map
*/
fn
values
(
block
(
V
));
fn
values
(
fn
(
V
));
}
// FIXME: package this up and export it as a datatype usable for
...
...
@@ -246,7 +246,7 @@ fn chains<K: copy, V: copy>(nchains: uint) -> [mutable chain<K,V>] {
}
fn
foreach_entry
<
K
:
copy
,
V
:
copy
>
(
chain0
:
chain
<
K
,
V
>
,
blk
:
block
(
@
entry
<
K
,
V
>
))
{
blk
:
fn
(
@
entry
<
K
,
V
>
))
{
let
chain
=
chain0
;
while
true
{
alt
chain
{
...
...
@@ -261,7 +261,7 @@ fn foreach_entry<K: copy, V: copy>(chain0: chain<K,V>,
}
fn
foreach_chain
<
K
:
copy
,
V
:
copy
>
(
chains
:
[
const
chain
<
K
,
V
>
],
blk
:
block
(
@
entry
<
K
,
V
>
))
{
blk
:
fn
(
@
entry
<
K
,
V
>
))
{
let
i
=
0u
,
n
=
vec
::
len
(
chains
);
while
i
<
n
{
foreach_entry
(
chains
[
i
],
blk
);
...
...
@@ -281,7 +281,7 @@ fn rehash<K: copy, V: copy>(tbl: t<K,V>) {
}
}
fn
items
<
K
:
copy
,
V
:
copy
>
(
tbl
:
t
<
K
,
V
>
,
blk
:
block
(
K
,
V
))
{
fn
items
<
K
:
copy
,
V
:
copy
>
(
tbl
:
t
<
K
,
V
>
,
blk
:
fn
(
K
,
V
))
{
let
tbl_chains
=
tbl
.chains
;
// Satisfy alias checker.
foreach_chain
(
tbl_chains
)
{
|
entry
|
let
key
=
entry
.key
;
...
...
@@ -310,11 +310,11 @@ fn find(k: K) -> option::t<V> { get(self, k) }
fn
remove
(
k
:
K
)
->
option
::
t
<
V
>
{
remove
(
self
,
k
)
}
fn
items
(
blk
:
block
(
K
,
V
))
{
items
(
self
,
blk
);
}
fn
items
(
blk
:
fn
(
K
,
V
))
{
items
(
self
,
blk
);
}
fn
keys
(
blk
:
block
(
K
))
{
items
(
self
)
{
|
k
,
_
v
|
blk
(
k
)
}
}
fn
keys
(
blk
:
fn
(
K
))
{
items
(
self
)
{
|
k
,
_
v
|
blk
(
k
)
}
}
fn
values
(
blk
:
block
(
V
))
{
items
(
self
)
{
|
_
k
,
v
|
blk
(
v
)
}
}
fn
values
(
blk
:
fn
(
V
))
{
items
(
self
)
{
|
_
k
,
v
|
blk
(
v
)
}
}
}
fn
mk
<
K
:
copy
,
V
:
copy
>
(
hasher
:
hashfn
<
K
>
,
eqer
:
eqfn
<
K
>
)
->
map
<
K
,
V
>
{
...
...
src/libstd/md4.rs
浏览文件 @
5e13d19c
...
...
@@ -81,7 +81,7 @@ fn rot(r: int, x: u32) -> u32 {
fn
md4_str
(
msg
:
[
u8
])
->
str
{
let
{
a
,
b
,
c
,
d
}
=
md4
(
msg
);
fn
app
(
a
:
u32
,
b
:
u32
,
c
:
u32
,
d
:
u32
,
f
:
block
(
u32
))
{
fn
app
(
a
:
u32
,
b
:
u32
,
c
:
u32
,
d
:
u32
,
f
:
fn
(
u32
))
{
f
(
a
);
f
(
b
);
f
(
c
);
f
(
d
);
}
let
result
=
""
;
...
...
src/libstd/rope.rs
浏览文件 @
5e13d19c
...
...
@@ -419,7 +419,7 @@ fn gt(left: rope, right: rope) -> bool {
`true` If execution proceeded correctly, `false` if it was interrupted,
that is if `it` returned `false` at any point.
*/
fn
loop_chars
(
rope
:
rope
,
it
:
block
(
char
)
->
bool
)
->
bool
{
fn
loop_chars
(
rope
:
rope
,
it
:
fn
(
char
)
->
bool
)
->
bool
{
alt
(
rope
)
{
node
::
empty
{
ret
true
}
node
::
content
(
x
)
{
ret
node
::
loop_chars
(
x
,
it
)
}
...
...
@@ -435,7 +435,7 @@ fn loop_chars(rope: rope, it: block(char) -> bool) -> bool {
rope - A rope to traverse. It may be empty
it - A block to execute with each consecutive character of the rope.
*/
fn
iter_chars
(
rope
:
rope
,
it
:
block
(
char
))
{
fn
iter_chars
(
rope
:
rope
,
it
:
fn
(
char
))
{
loop_chars
(
rope
)
{|
x
|
it
(
x
);
ret
true
...
...
@@ -466,7 +466,7 @@ fn iter_chars(rope: rope, it: block(char)) {
`true` If execution proceeded correctly, `false` if it was interrupted,
that is if `it` returned `false` at any point.
*/
fn
loop_leaves
(
rope
:
rope
,
it
:
block
(
node
::
leaf
)
->
bool
)
->
bool
{
fn
loop_leaves
(
rope
:
rope
,
it
:
fn
(
node
::
leaf
)
->
bool
)
->
bool
{
alt
(
rope
)
{
node
::
empty
{
ret
true
}
node
::
content
(
x
)
{
ret
node
::
loop_leaves
(
x
,
it
)}
...
...
@@ -1135,7 +1135,7 @@ fn cmp(a: @node, b: @node) -> int {
ret
result
;
}
fn
loop_chars
(
node
:
@
node
,
it
:
block
(
char
)
->
bool
)
->
bool
{
fn
loop_chars
(
node
:
@
node
,
it
:
fn
(
char
)
->
bool
)
->
bool
{
ret
loop_leaves
(
node
,
{|
leaf
|
ret
str
::
loop_chars_sub
(
*
leaf
.content
,
leaf
.byte_offset
,
...
...
@@ -1159,7 +1159,7 @@ fn loop_chars(node: @node, it: block(char) -> bool) -> bool {
`true` If execution proceeded correctly, `false` if it was interrupted,
that is if `it` returned `false` at any point.
*/
fn
loop_leaves
(
node
:
@
node
,
it
:
block
(
leaf
)
->
bool
)
->
bool
{
fn
loop_leaves
(
node
:
@
node
,
it
:
fn
(
leaf
)
->
bool
)
->
bool
{
let
current
=
node
;
while
true
{
alt
(
*
current
)
{
...
...
src/libstd/smallintmap.rs
浏览文件 @
5e13d19c
...
...
@@ -110,7 +110,7 @@ fn contains_key(&&key: uint) -> bool {
fn
get
(
&&
key
:
uint
)
->
V
{
get
(
self
,
key
)
}
fn
find
(
&&
key
:
uint
)
->
option
::
t
<
V
>
{
find
(
self
,
key
)
}
fn
rehash
()
{
fail
}
fn
items
(
it
:
block
(
&&
uint
,
V
))
{
fn
items
(
it
:
fn
(
&&
uint
,
V
))
{
let
idx
=
0u
;
for
item
in
self
.v
{
alt
item
{
...
...
@@ -122,14 +122,14 @@ fn items(it: block(&&uint, V)) {
idx
+=
1u
;
}
}
fn
keys
(
it
:
block
(
&&
uint
))
{
fn
keys
(
it
:
fn
(
&&
uint
))
{
let
idx
=
0u
;
for
item
in
self
.v
{
if
item
!=
none
{
it
(
idx
);
}
idx
+=
1u
;
}
}
fn
values
(
it
:
block
(
V
))
{
fn
values
(
it
:
fn
(
V
))
{
for
item
in
self
.v
{
alt
item
{
some
(
elt
)
{
it
(
elt
);
}
_
{}
}
}
...
...
src/libstd/sort.rs
浏览文件 @
5e13d19c
...
...
@@ -10,7 +10,7 @@
export
quick_sort3
;
/* Type: lteq */
type
lteq
<
T
>
=
block
(
T
,
T
)
->
bool
;
type
lteq
<
T
>
=
fn
(
T
,
T
)
->
bool
;
/*
Function: merge_sort
...
...
src/libstd/treemap.rs
浏览文件 @
5e13d19c
...
...
@@ -83,7 +83,7 @@ fn find<K: copy, V: copy>(m: treemap<K, V>, k: K) -> option<V> {
Visit all pairs in the map in order.
*/
fn
traverse
<
K
,
V
>
(
m
:
treemap
<
K
,
V
>
,
f
:
block
(
K
,
V
))
{
fn
traverse
<
K
,
V
>
(
m
:
treemap
<
K
,
V
>
,
f
:
fn
(
K
,
V
))
{
alt
*
m
{
empty
{
}
node
(
k
,
v
,
_
,
_
)
{
...
...
src/libstd/tri.rs
浏览文件 @
5e13d19c
...
...
@@ -164,7 +164,7 @@
Iterates over all truth values by passing them to `blk`
in an unspecified order
*/
fn
all_values
(
blk
:
block
(
v
:
t
))
{
fn
all_values
(
blk
:
fn
(
v
:
t
))
{
blk
(
tri
::
false
);
blk
(
unknown
);
blk
(
tri
::
true
);
...
...
src/test/bench/99bob-iter.rs
浏览文件 @
5e13d19c
...
...
@@ -40,7 +40,7 @@ fn sub(t: str, n: int) -> str {
/* Using an interator */
fn
ninetynine
(
it
:
block
(
int
))
{
fn
ninetynine
(
it
:
fn
(
int
))
{
let
n
:
int
=
100
;
while
n
>
1
{
n
-=
1
;
it
(
n
);
}
}
...
...
src/test/compile-fail/block-arg-used-as-lambda-with-illegal-cap.rs
浏览文件 @
5e13d19c
...
...
@@ -4,7 +4,7 @@ fn to_lambda1(f: fn@(uint) -> uint) -> fn@(uint) -> uint {
ret
f
;
}
fn
to_lambda2
(
b
:
block
(
uint
)
->
uint
)
->
fn
@
(
uint
)
->
uint
{
fn
to_lambda2
(
b
:
fn
(
uint
)
->
uint
)
->
fn
@
(
uint
)
->
uint
{
ret
to_lambda1
({|
x
|
b
(
x
)});
}
...
...
src/test/compile-fail/block-coerce-no.rs
浏览文件 @
5e13d19c
...
...
@@ -2,11 +2,11 @@
// other tycons.
fn
coerce
(
b
:
fn
())
->
native
fn
()
{
fn
lol
(
f
:
native
fn
(
block
())
->
native
fn
(),
fn
lol
(
f
:
native
fn
(
fn
())
->
native
fn
(),
g
:
fn
())
->
native
fn
()
{
ret
f
(
g
);
}
fn
fn_id
(
f
:
native
fn
())
->
native
fn
()
{
ret
f
}
ret
lol
(
fn_id
,
b
);
//!^ ERROR mismatched types: expected `native fn(fn
&
()) -> native fn()`
//!^ ERROR mismatched types: expected `native fn(fn()) -> native fn()`
}
fn
main
()
{
...
...
src/test/compile-fail/block-copy.rs
浏览文件 @
5e13d19c
// error-pattern: block type can only appear
fn
lol
(
f
:
block
())
->
block
()
{
ret
f
;
}
fn
lol
(
f
:
fn
())
->
fn
()
{
ret
f
;
}
fn
main
()
{
let
i
=
8
;
let
f
=
lol
(
block
()
{
log
(
error
,
i
);
});
let
f
=
lol
(
fn
&
()
{
log
(
error
,
i
);
});
f
();
}
src/test/compile-fail/block-deinitializes-upvar.rs
浏览文件 @
5e13d19c
// error-pattern:Tried to deinitialize a variable declared in a different
fn
force
(
f
:
block
())
{
f
();
}
fn
force
(
f
:
fn
())
{
f
();
}
fn
main
()
{
let
x
=
@
{
x
:
17
,
y
:
2
};
let
y
=
@
{
x
:
5
,
y
:
5
};
...
...
src/test/compile-fail/block-require-return.rs
浏览文件 @
5e13d19c
// error-pattern: not all control paths return
fn
force
(
f
:
block
()
->
int
)
->
int
{
f
()
}
fn
force
(
f
:
fn
()
->
int
)
->
int
{
f
()
}
fn
main
()
{
log
(
error
,
force
({||
}));
}
src/test/compile-fail/block-uninit.rs
浏览文件 @
5e13d19c
// error-pattern: Unsatisfied precondition constraint
fn
force
(
f
:
block
())
{
f
();
}
fn
main
()
{
let
x
:
int
;
force
(
block
()
{
log
(
error
,
x
);
});
}
fn
force
(
f
:
fn
())
{
f
();
}
fn
main
()
{
let
x
:
int
;
force
(
fn
&
()
{
log
(
error
,
x
);
});
}
src/test/compile-fail/cap-clause-illegal-cap.rs
浏览文件 @
5e13d19c
// error-pattern: copying a noncopyable value
fn
to_lambda2
(
b
:
block
(
uint
)
->
uint
)
->
fn
@
(
uint
)
->
uint
{
fn
to_lambda2
(
b
:
fn
(
uint
)
->
uint
)
->
fn
@
(
uint
)
->
uint
{
// test case where copy clause specifies a value that is not used
// in fn@ body, but value is illegal to copy:
ret
fn
@
[
copy
b
](
u
:
uint
)
->
uint
{
22u
};
...
...
src/test/compile-fail/lambda-mutate-nested.rs
浏览文件 @
5e13d19c
// error-pattern:assigning to upvar
// Make sure that nesting a block within a fn@ doesn't let us
// mutate upvars from a fn@.
fn
f2
(
x
:
block
())
{
x
();
}
fn
f2
(
x
:
fn
())
{
x
();
}
fn
main
()
{
let
i
=
0
;
...
...
src/test/pretty/block-arg-disambig.rs
浏览文件 @
5e13d19c
fn
blk1
(
b
:
block
())
->
fn
@
()
{
ret
fn
@
()
{
};
}
fn
blk1
(
b
:
fn
())
->
fn
@
()
{
ret
fn
@
()
{
};
}
fn
test1
()
{
(
blk1
{||
#
debug
[
"hi"
];
})();
}
src/test/run-fail/unwind-iter.rs
浏览文件 @
5e13d19c
// error-pattern:fail
fn
x
(
it
:
block
(
int
))
{
fn
x
(
it
:
fn
(
int
))
{
fail
;
it
(
0
);
}
...
...
src/test/run-fail/unwind-iter2.rs
浏览文件 @
5e13d19c
// error-pattern:fail
fn
x
(
it
:
block
(
int
))
{
fn
x
(
it
:
fn
(
int
))
{
let
a
=
@
0
;
it
(
1
);
}
...
...
src/test/run-fail/unwind-lambda.rs
浏览文件 @
5e13d19c
...
...
@@ -4,7 +4,7 @@ fn main() {
let
cheese
=
"roquefort"
;
let
carrots
=
@
"crunchy"
;
fn
@
(
tasties
:
@
str
,
macerate
:
block
(
str
))
{
fn
@
(
tasties
:
@
str
,
macerate
:
fn
(
str
))
{
macerate
(
*
tasties
);
}
(
carrots
,
{
|
food
|
let
mush
=
food
+
cheese
;
...
...
src/test/run-pass/alt-phi.rs
浏览文件 @
5e13d19c
...
...
@@ -2,7 +2,7 @@
enum
thing
{
a
,
b
,
c
,
}
fn
foo
(
it
:
block
(
int
))
{
it
(
10
);
}
fn
foo
(
it
:
fn
(
int
))
{
it
(
10
);
}
fn
main
()
{
let
x
=
true
;
...
...
src/test/run-pass/argument-passing.rs
浏览文件 @
5e13d19c
...
...
@@ -6,7 +6,7 @@ fn f1(a: {mutable x: int}, &b: int, -c: int) -> int {
ret
r
;
}
fn
f2
(
a
:
int
,
f
:
block
(
int
))
->
int
{
f
(
1
);
ret
a
;
}
fn
f2
(
a
:
int
,
f
:
fn
(
int
))
->
int
{
f
(
1
);
ret
a
;
}
fn
main
()
{
let
a
=
{
mutable
x
:
1
},
b
=
2
,
c
=
3
;
...
...
src/test/run-pass/block-arg-call-as.rs
浏览文件 @
5e13d19c
...
...
@@ -8,7 +8,11 @@ fn asLambda( f : fn@()->uint ) -> uint {
ret
f
();
}
fn
asBlock
(
f
:
block
()
->
uint
)
->
uint
{
fn
asBlock
(
f
:
fn
&
()
->
uint
)
->
uint
{
ret
f
();
}
fn
asAny
(
f
:
fn
()
->
uint
)
->
uint
{
ret
f
();
}
...
...
src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs
浏览文件 @
5e13d19c
fn
main
()
{
fn
f
(
i
:
block
()
->
uint
)
->
uint
{
i
()
}
fn
f
(
i
:
fn
()
->
uint
)
->
uint
{
i
()
}
let
v
=
[
-
1
f
,
0
f
,
1
f
,
2
f
,
3
f
];
let
z
=
vec
::
foldl
(
f
,
v
)
{
|
x
,
_
y
|
x
}
{
||
22u
};
assert
z
==
22u
;
...
...
src/test/run-pass/block-explicit-types.rs
浏览文件 @
5e13d19c
fn
main
()
{
fn
as_buf
<
T
>
(
s
:
str
,
f
:
block
(
str
)
->
T
)
->
T
{
f
(
s
)
}
fn
as_buf
<
T
>
(
s
:
str
,
f
:
fn
(
str
)
->
T
)
->
T
{
f
(
s
)
}
as_buf
(
"foo"
,
{|
foo
:
str
|
->
()
log
(
error
,
foo
);});
}
src/test/run-pass/block-fn-coerce.rs
浏览文件 @
5e13d19c
fn
force
(
f
:
block
()
->
int
)
->
int
{
ret
f
();
}
fn
force
(
f
:
fn
()
->
int
)
->
int
{
ret
f
();
}
fn
main
()
{
fn
f
()
->
int
{
ret
7
;
}
assert
(
force
(
f
)
==
7
);
...
...
src/test/run-pass/block-iter-1.rs
浏览文件 @
5e13d19c
fn
iter_vec
<
T
>
(
v
:
[
T
],
f
:
block
(
T
))
{
for
x
:
T
in
v
{
f
(
x
);
}
}
fn
iter_vec
<
T
>
(
v
:
[
T
],
f
:
fn
(
T
))
{
for
x
:
T
in
v
{
f
(
x
);
}
}
fn
main
()
{
let
v
=
[
1
,
2
,
3
,
4
,
5
,
6
,
7
];
...
...
src/test/run-pass/block-iter-2.rs
浏览文件 @
5e13d19c
fn
iter_vec
<
T
>
(
v
:
[
T
],
f
:
block
(
T
))
{
for
x
:
T
in
v
{
f
(
x
);
}
}
fn
iter_vec
<
T
>
(
v
:
[
T
],
f
:
fn
(
T
))
{
for
x
:
T
in
v
{
f
(
x
);
}
}
fn
main
()
{
let
v
=
[
1
,
2
,
3
,
4
,
5
];
...
...
src/test/run-pass/fn-bare-coerce-to-block.rs
浏览文件 @
5e13d19c
fn
bare
()
{}
fn
likes_block
(
f
:
block
())
{
f
()
}
fn
likes_block
(
f
:
fn
())
{
f
()
}
fn
main
()
{
likes_block
(
bare
);
...
...
src/test/run-pass/foreach-nested.rs
浏览文件 @
5e13d19c
...
...
@@ -2,7 +2,7 @@
// -*- rust -*-
fn
two
(
it
:
block
(
int
))
{
it
(
0
);
it
(
1
);
}
fn
two
(
it
:
fn
(
int
))
{
it
(
0
);
it
(
1
);
}
fn
main
()
{
let
a
:
[
mutable
int
]
=
[
mutable
-
1
,
-
1
,
-
1
,
-
1
];
...
...
src/test/run-pass/foreach-put-structured.rs
浏览文件 @
5e13d19c
fn
pairs
(
it
:
block
((
int
,
int
)))
{
fn
pairs
(
it
:
fn
((
int
,
int
)))
{
let
i
:
int
=
0
;
let
j
:
int
=
0
;
while
i
<
10
{
it
((
i
,
j
));
i
+=
1
;
j
+=
i
;
}
...
...
src/test/run-pass/foreach-simple-outer-slot.rs
浏览文件 @
5e13d19c
...
...
@@ -10,7 +10,7 @@ fn main() {
assert
(
sum
==
45
);
}
fn
first_ten
(
it
:
block
(
int
))
{
fn
first_ten
(
it
:
fn
(
int
))
{
let
i
:
int
=
0
;
while
i
<
10
{
#
debug
(
"first_ten"
);
it
(
i
);
i
=
i
+
1
;
}
}
src/test/run-pass/iface-generic.rs
浏览文件 @
5e13d19c
...
...
@@ -12,10 +12,10 @@ fn to_str() -> str { "()" }
}
iface
map
<
T
>
{
fn
map
<
U
>
(
f
:
block
(
T
)
->
U
)
->
[
U
];
fn
map
<
U
>
(
f
:
fn
(
T
)
->
U
)
->
[
U
];
}
impl
<
T
>
of
map
<
T
>
for
[
T
]
{
fn
map
<
U
>
(
f
:
block
(
T
)
->
U
)
->
[
U
]
{
fn
map
<
U
>
(
f
:
fn
(
T
)
->
U
)
->
[
U
]
{
let
r
=
[];
for
x
in
self
{
r
+=
[
f
(
x
)];
}
r
...
...
src/test/run-pass/iter-range.rs
浏览文件 @
5e13d19c
fn
range
(
a
:
int
,
b
:
int
,
it
:
block
(
int
))
{
fn
range
(
a
:
int
,
b
:
int
,
it
:
fn
(
int
))
{
assert
(
a
<
b
);
let
i
:
int
=
a
;
while
i
<
b
{
it
(
i
);
i
+=
1
;
}
...
...
src/test/run-pass/sendfn-is-a-block.rs
浏览文件 @
5e13d19c
fn
test
(
f
:
block
(
uint
)
->
uint
)
->
uint
{
fn
test
(
f
:
fn
(
uint
)
->
uint
)
->
uint
{
ret
f
(
22u
);
}
...
...
src/test/run-pass/static-impl.rs
浏览文件 @
5e13d19c
...
...
@@ -11,7 +11,7 @@ impl baz for str { fn plus() -> int { 200 } }
impl
util
for
uint
{
fn
str
()
->
str
{
uint
::
str
(
self
)
}
fn
times
(
f
:
block
(
uint
))
{
fn
times
(
f
:
fn
(
uint
))
{
let
c
=
0u
;
while
c
<
self
{
f
(
c
);
c
+=
1u
;
}
}
...
...
@@ -19,8 +19,8 @@ fn times(f: block(uint)) {
impl
util
<
T
>
for
[
T
]
{
fn
len
()
->
uint
{
vec
::
len
(
self
)
}
fn
iter
(
f
:
block
(
T
))
{
for
x
in
self
{
f
(
x
);
}
}
fn
map
<
U
>
(
f
:
block
(
T
)
->
U
)
->
[
U
]
{
fn
iter
(
f
:
fn
(
T
))
{
for
x
in
self
{
f
(
x
);
}
}
fn
map
<
U
>
(
f
:
fn
(
T
)
->
U
)
->
[
U
]
{
let
r
=
[];
for
elt
in
self
{
r
+=
[
f
(
elt
)];
}
r
...
...
src/test/run-pass/type-params-in-for-each.rs
浏览文件 @
5e13d19c
fn
range
(
lo
:
uint
,
hi
:
uint
,
it
:
block
(
uint
))
{
fn
range
(
lo
:
uint
,
hi
:
uint
,
it
:
fn
(
uint
))
{
let
lo_
=
lo
;
while
lo_
<
hi
{
it
(
lo_
);
lo_
+=
1u
;
}
}
...
...
src/test/run-pass/unchecked-predicates.rs
浏览文件 @
5e13d19c
...
...
@@ -7,7 +7,7 @@
// Can't easily be written as a "pure fn" because there's
// no syntax for specifying that f is pure.
fn
pure_foldl
<
T
:
copy
,
U
:
copy
>
(
ls
:
list
<
T
>
,
u
:
U
,
f
:
block
(
T
,
U
)
->
U
)
->
U
{
fn
pure_foldl
<
T
:
copy
,
U
:
copy
>
(
ls
:
list
<
T
>
,
u
:
U
,
f
:
fn
(
T
,
U
)
->
U
)
->
U
{
alt
ls
{
nil
{
u
}
cons
(
hd
,
tl
)
{
f
(
hd
,
pure_foldl
(
*
tl
,
f
(
hd
,
u
),
f
))
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录