Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b106ef81
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,发现更多精彩内容 >>
提交
b106ef81
编写于
2月 07, 2012
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make bind syntax unnecessary: just use _ for one of the arguments
上级
fc023d91
变更
30
隐藏空白更改
内联
并排
Showing
30 changed file
with
66 addition
and
55 deletion
+66
-55
src/comp/syntax/parse/parser.rs
src/comp/syntax/parse/parser.rs
+20
-11
src/comp/syntax/print/pprust.rs
src/comp/syntax/print/pprust.rs
+6
-1
src/test/run-pass/bind-parameterized-args-2.rs
src/test/run-pass/bind-parameterized-args-2.rs
+1
-1
src/test/run-pass/bind-parameterized-args.rs
src/test/run-pass/bind-parameterized-args.rs
+1
-1
src/test/run-pass/bind-trivial.rs
src/test/run-pass/bind-trivial.rs
+1
-1
src/test/run-pass/drop-bind-thunk-args.rs
src/test/run-pass/drop-bind-thunk-args.rs
+1
-1
src/test/run-pass/drop-parametric-closure-with-bound-box.rs
src/test/run-pass/drop-parametric-closure-with-bound-box.rs
+1
-1
src/test/run-pass/expr-alt-generic-box1.rs
src/test/run-pass/expr-alt-generic-box1.rs
+1
-1
src/test/run-pass/expr-alt-generic-box2.rs
src/test/run-pass/expr-alt-generic-box2.rs
+1
-1
src/test/run-pass/expr-alt-generic-unique1.rs
src/test/run-pass/expr-alt-generic-unique1.rs
+1
-1
src/test/run-pass/expr-alt-generic-unique2.rs
src/test/run-pass/expr-alt-generic-unique2.rs
+1
-1
src/test/run-pass/expr-alt-generic.rs
src/test/run-pass/expr-alt-generic.rs
+2
-2
src/test/run-pass/expr-block-generic-box1.rs
src/test/run-pass/expr-block-generic-box1.rs
+1
-1
src/test/run-pass/expr-block-generic-box2.rs
src/test/run-pass/expr-block-generic-box2.rs
+1
-1
src/test/run-pass/expr-block-generic-unique1.rs
src/test/run-pass/expr-block-generic-unique1.rs
+1
-1
src/test/run-pass/expr-block-generic-unique2.rs
src/test/run-pass/expr-block-generic-unique2.rs
+1
-1
src/test/run-pass/expr-block-generic.rs
src/test/run-pass/expr-block-generic.rs
+2
-2
src/test/run-pass/expr-if-generic-box1.rs
src/test/run-pass/expr-if-generic-box1.rs
+1
-1
src/test/run-pass/expr-if-generic-box2.rs
src/test/run-pass/expr-if-generic-box2.rs
+1
-1
src/test/run-pass/expr-if-generic.rs
src/test/run-pass/expr-if-generic.rs
+2
-2
src/test/run-pass/fixed-point-bind-box.rs
src/test/run-pass/fixed-point-bind-box.rs
+2
-2
src/test/run-pass/fixed-point-bind-unique.rs
src/test/run-pass/fixed-point-bind-unique.rs
+2
-2
src/test/run-pass/fun-call-variants.rs
src/test/run-pass/fun-call-variants.rs
+1
-1
src/test/run-pass/generic-bind.rs
src/test/run-pass/generic-bind.rs
+7
-7
src/test/run-pass/hashmap-memory.rs
src/test/run-pass/hashmap-memory.rs
+1
-1
src/test/run-pass/issue-333.rs
src/test/run-pass/issue-333.rs
+1
-1
src/test/run-pass/issue-898.rs
src/test/run-pass/issue-898.rs
+1
-1
src/test/run-pass/rebind-fn.rs
src/test/run-pass/rebind-fn.rs
+1
-1
src/test/run-pass/task-comm-17.rs
src/test/run-pass/task-comm-17.rs
+2
-5
src/test/run-pass/unchecked-predicates.rs
src/test/run-pass/unchecked-predicates.rs
+1
-1
未找到文件。
src/comp/syntax/parse/parser.rs
浏览文件 @
b106ef81
...
...
@@ -854,15 +854,9 @@ fn parse_bottom_expr(p: parser) -> pexpr {
ret
pexpr
(
mk_mac_expr
(
p
,
lo
,
p
.span.hi
,
ast
::
mac_ellipsis
));
}
else
if
eat_word
(
p
,
"bind"
)
{
let
e
=
parse_expr_res
(
p
,
RESTRICT_NO_CALL_EXPRS
);
fn
parse_expr_opt
(
p
:
parser
)
->
option
<@
ast
::
expr
>
{
alt
p
.token
{
token
::
UNDERSCORE
{
p
.bump
();
ret
none
;
}
_
{
ret
some
(
parse_expr
(
p
));
}
}
}
let
es
=
parse_seq
(
token
::
LPAREN
,
token
::
RPAREN
,
seq_sep
(
token
::
COMMA
),
parse_expr_o
pt
,
p
);
parse_expr_o
r_hole
,
p
);
hi
=
es
.span.hi
;
ex
=
ast
::
expr_bind
(
e
,
es
.node
);
}
else
if
p
.token
==
token
::
POUND
{
...
...
@@ -1036,10 +1030,18 @@ fn parse_dot_or_call_expr_with(p: parser, e0: pexpr) -> pexpr {
alt
p
.token
{
// expr(...)
token
::
LPAREN
if
permits_call
(
p
)
{
let
es
=
parse_seq
(
token
::
LPAREN
,
token
::
RPAREN
,
seq_sep
(
token
::
COMMA
),
parse_expr
,
p
);
hi
=
es
.span.hi
;
let
nd
=
ast
::
expr_call
(
to_expr
(
e
),
es
.node
,
false
);
let
es_opt
=
parse_seq
(
token
::
LPAREN
,
token
::
RPAREN
,
seq_sep
(
token
::
COMMA
),
parse_expr_or_hole
,
p
);
hi
=
es_opt
.span.hi
;
let
nd
=
if
vec
::
any
(
es_opt
.node
,
{|
e
|
option
::
is_none
(
e
)
})
{
ast
::
expr_bind
(
to_expr
(
e
),
es_opt
.node
)
}
else
{
let
es
=
vec
::
map
(
es_opt
.node
)
{|
e
|
option
::
get
(
e
)
};
ast
::
expr_call
(
to_expr
(
e
),
es
,
false
)
};
e
=
mk_pexpr
(
p
,
lo
,
hi
,
nd
);
}
...
...
@@ -1388,6 +1390,13 @@ fn parse_expr(p: parser) -> @ast::expr {
ret
parse_expr_res
(
p
,
UNRESTRICTED
);
}
fn
parse_expr_or_hole
(
p
:
parser
)
->
option
<@
ast
::
expr
>
{
alt
p
.token
{
token
::
UNDERSCORE
{
p
.bump
();
ret
none
;
}
_
{
ret
some
(
parse_expr
(
p
));
}
}
}
fn
parse_expr_res
(
p
:
parser
,
r
:
restriction
)
->
@
ast
::
expr
{
let
old
=
p
.restriction
;
p
.restriction
=
r
;
...
...
src/comp/syntax/print/pprust.rs
浏览文件 @
b106ef81
...
...
@@ -846,7 +846,12 @@ fn print_opt(s: ps, expr: option<@ast::expr>) {
_
{
word
(
s
.s
,
"_"
);
}
}
}
word_nbsp
(
s
,
"bind"
);
// "bind" keyword is only needed if there are no "_" arguments.
if
!
vec
::
any
(
args
)
{|
arg
|
option
::
is_none
(
arg
)
}
{
word_nbsp
(
s
,
"bind"
);
}
print_expr
(
s
,
func
);
popen
(
s
);
commasep
(
s
,
inconsistent
,
args
,
print_opt
);
...
...
src/test/run-pass/bind-parameterized-args-2.rs
浏览文件 @
b106ef81
fn
main
()
{
fn
echo
<
T
>
(
c
:
int
,
x
:
fn
@
(
T
))
{
#
error
(
"wee"
);
}
let
y
=
bind
echo
(
42
,
_
);
let
y
=
echo
(
42
,
_
);
y
(
fn
@
(
&&
i
:
str
)
{
});
}
src/test/run-pass/bind-parameterized-args.rs
浏览文件 @
b106ef81
fn
main
()
{
fn
echo
<
T
>
(
c
:
int
,
x
:
[
T
])
{
}
let
y
:
fn
@
([
int
])
=
bind
echo
(
42
,
_
);
let
y
:
fn
@
([
int
])
=
echo
(
42
,
_
);
y
([
1
]);
}
src/test/run-pass/bind-trivial.rs
浏览文件 @
b106ef81
...
...
@@ -5,7 +5,7 @@
fn
f
(
n
:
int
)
->
int
{
ret
n
;
}
fn
main
()
{
let
g
:
fn
@
(
int
)
->
int
=
bind
f
(
_
);
let
g
:
fn
@
(
int
)
->
int
=
f
(
_
);
let
i
:
int
=
g
(
42
);
assert
(
i
==
42
);
}
src/test/run-pass/drop-bind-thunk-args.rs
浏览文件 @
b106ef81
...
...
@@ -2,4 +2,4 @@
fn
f
(
x
:
@
int
)
{
}
fn
main
()
{
let
x
=
@
10
;
let
ff
=
bind
f
(
_
);
ff
(
x
);
ff
(
x
);
}
fn
main
()
{
let
x
=
@
10
;
let
ff
=
f
(
_
);
ff
(
x
);
ff
(
x
);
}
src/test/run-pass/drop-parametric-closure-with-bound-box.rs
浏览文件 @
b106ef81
...
...
@@ -2,4 +2,4 @@
fn
f
<
T
>
(
i
:
@
uint
,
t
:
T
)
{
}
fn
main
()
{
let
x
=
bind
f
::
<
char
>
(
@
0xdeafbeefu
,
_
);
}
fn
main
()
{
let
x
=
f
::
<
char
>
(
@
0xdeafbeefu
,
_
);
}
src/test/run-pass/expr-alt-generic-box1.rs
浏览文件 @
b106ef81
...
...
@@ -11,7 +11,7 @@ fn test_generic<T>(expected: @T, eq: compare<T>) {
fn
test_box
()
{
fn
compare_box
(
b1
:
@
bool
,
b2
:
@
bool
)
->
bool
{
ret
*
b1
==
*
b2
;
}
let
eq
=
bind
compare_box
(
_
,
_
);
let
eq
=
compare_box
(
_
,
_
);
test_generic
::
<
bool
>
(
@
true
,
eq
);
}
...
...
src/test/run-pass/expr-alt-generic-box2.rs
浏览文件 @
b106ef81
...
...
@@ -11,7 +11,7 @@ fn test_generic<T: copy>(expected: T, eq: compare<T>) {
fn
test_vec
()
{
fn
compare_box
(
&&
v1
:
@
int
,
&&
v2
:
@
int
)
->
bool
{
ret
v1
==
v2
;
}
let
eq
=
bind
compare_box
(
_
,
_
);
let
eq
=
compare_box
(
_
,
_
);
test_generic
::
<@
int
>
(
@
1
,
eq
);
}
...
...
src/test/run-pass/expr-alt-generic-unique1.rs
浏览文件 @
b106ef81
...
...
@@ -10,7 +10,7 @@ fn test_generic<T: copy>(expected: ~T, eq: compare<T>) {
fn
test_box
()
{
fn
compare_box
(
b1
:
~
bool
,
b2
:
~
bool
)
->
bool
{
ret
*
b1
==
*
b2
;
}
let
eq
=
bind
compare_box
(
_
,
_
);
let
eq
=
compare_box
(
_
,
_
);
test_generic
::
<
bool
>
(
~
true
,
eq
);
}
...
...
src/test/run-pass/expr-alt-generic-unique2.rs
浏览文件 @
b106ef81
...
...
@@ -11,7 +11,7 @@ fn test_generic<T: copy>(expected: T, eq: compare<T>) {
fn
test_vec
()
{
fn
compare_box
(
&&
v1
:
~
int
,
&&
v2
:
~
int
)
->
bool
{
ret
v1
==
v2
;
}
let
eq
=
bind
compare_box
(
_
,
_
);
let
eq
=
compare_box
(
_
,
_
);
test_generic
::
<~
int
>
(
~
1
,
eq
);
}
...
...
src/test/run-pass/expr-alt-generic.rs
浏览文件 @
b106ef81
...
...
@@ -11,7 +11,7 @@ fn test_generic<T: copy>(expected: T, eq: compare<T>) {
fn
test_bool
()
{
fn
compare_bool
(
&&
b1
:
bool
,
&&
b2
:
bool
)
->
bool
{
ret
b1
==
b2
;
}
let
eq
=
bind
compare_bool
(
_
,
_
);
let
eq
=
compare_bool
(
_
,
_
);
test_generic
::
<
bool
>
(
true
,
eq
);
}
...
...
@@ -19,7 +19,7 @@ fn test_rec() {
type
t
=
{
a
:
int
,
b
:
int
};
fn
compare_rec
(
t1
:
t
,
t2
:
t
)
->
bool
{
ret
t1
==
t2
;
}
let
eq
=
bind
compare_rec
(
_
,
_
);
let
eq
=
compare_rec
(
_
,
_
);
test_generic
::
<
t
>
({
a
:
1
,
b
:
2
},
eq
);
}
...
...
src/test/run-pass/expr-block-generic-box1.rs
浏览文件 @
b106ef81
...
...
@@ -15,7 +15,7 @@ fn compare_box(b1: @bool, b2: @bool) -> bool {
log
(
debug
,
*
b2
);
ret
*
b1
==
*
b2
;
}
let
eq
=
bind
compare_box
(
_
,
_
);
let
eq
=
compare_box
(
_
,
_
);
test_generic
::
<
bool
>
(
@
true
,
eq
);
}
...
...
src/test/run-pass/expr-block-generic-box2.rs
浏览文件 @
b106ef81
...
...
@@ -11,7 +11,7 @@ fn test_generic<T: copy>(expected: T, eq: compare<T>) {
fn
test_vec
()
{
fn
compare_vec
(
&&
v1
:
@
int
,
&&
v2
:
@
int
)
->
bool
{
ret
v1
==
v2
;
}
let
eq
=
bind
compare_vec
(
_
,
_
);
let
eq
=
compare_vec
(
_
,
_
);
test_generic
::
<@
int
>
(
@
1
,
eq
);
}
...
...
src/test/run-pass/expr-block-generic-unique1.rs
浏览文件 @
b106ef81
...
...
@@ -14,7 +14,7 @@ fn compare_box(b1: ~bool, b2: ~bool) -> bool {
log
(
debug
,
*
b2
);
ret
*
b1
==
*
b2
;
}
let
eq
=
bind
compare_box
(
_
,
_
);
let
eq
=
compare_box
(
_
,
_
);
test_generic
::
<
bool
>
(
~
true
,
eq
);
}
...
...
src/test/run-pass/expr-block-generic-unique2.rs
浏览文件 @
b106ef81
...
...
@@ -11,7 +11,7 @@ fn test_generic<T: copy>(expected: T, eq: compare<T>) {
fn
test_vec
()
{
fn
compare_vec
(
&&
v1
:
~
int
,
&&
v2
:
~
int
)
->
bool
{
ret
v1
==
v2
;
}
let
eq
=
bind
compare_vec
(
_
,
_
);
let
eq
=
compare_vec
(
_
,
_
);
test_generic
::
<~
int
>
(
~
1
,
eq
);
}
...
...
src/test/run-pass/expr-block-generic.rs
浏览文件 @
b106ef81
...
...
@@ -13,7 +13,7 @@ fn test_generic<T: copy>(expected: T, eq: compare<T>) {
fn
test_bool
()
{
fn
compare_bool
(
&&
b1
:
bool
,
&&
b2
:
bool
)
->
bool
{
ret
b1
==
b2
;
}
let
eq
=
bind
compare_bool
(
_
,
_
);
let
eq
=
compare_bool
(
_
,
_
);
test_generic
::
<
bool
>
(
true
,
eq
);
}
...
...
@@ -21,7 +21,7 @@ fn test_rec() {
type
t
=
{
a
:
int
,
b
:
int
};
fn
compare_rec
(
t1
:
t
,
t2
:
t
)
->
bool
{
ret
t1
==
t2
;
}
let
eq
=
bind
compare_rec
(
_
,
_
);
let
eq
=
compare_rec
(
_
,
_
);
test_generic
::
<
t
>
({
a
:
1
,
b
:
2
},
eq
);
}
...
...
src/test/run-pass/expr-if-generic-box1.rs
浏览文件 @
b106ef81
...
...
@@ -11,7 +11,7 @@ fn test_generic<T>(expected: @T, not_expected: @T, eq: compare<T>) {
fn
test_box
()
{
fn
compare_box
(
b1
:
@
bool
,
b2
:
@
bool
)
->
bool
{
ret
*
b1
==
*
b2
;
}
let
eq
=
bind
compare_box
(
_
,
_
);
let
eq
=
compare_box
(
_
,
_
);
test_generic
::
<
bool
>
(
@
true
,
@
false
,
eq
);
}
...
...
src/test/run-pass/expr-if-generic-box2.rs
浏览文件 @
b106ef81
...
...
@@ -11,7 +11,7 @@ fn test_generic<T: copy>(expected: T, not_expected: T, eq: compare<T>) {
fn
test_vec
()
{
fn
compare_box
(
&&
v1
:
@
int
,
&&
v2
:
@
int
)
->
bool
{
ret
v1
==
v2
;
}
let
eq
=
bind
compare_box
(
_
,
_
);
let
eq
=
compare_box
(
_
,
_
);
test_generic
::
<@
int
>
(
@
1
,
@
2
,
eq
);
}
...
...
src/test/run-pass/expr-if-generic.rs
浏览文件 @
b106ef81
...
...
@@ -13,7 +13,7 @@ fn test_generic<T: copy>(expected: T, not_expected: T, eq: compare<T>) {
fn
test_bool
()
{
fn
compare_bool
(
&&
b1
:
bool
,
&&
b2
:
bool
)
->
bool
{
ret
b1
==
b2
;
}
let
eq
=
bind
compare_bool
(
_
,
_
);
let
eq
=
compare_bool
(
_
,
_
);
test_generic
::
<
bool
>
(
true
,
false
,
eq
);
}
...
...
@@ -21,7 +21,7 @@ fn test_rec() {
type
t
=
{
a
:
int
,
b
:
int
};
fn
compare_rec
(
t1
:
t
,
t2
:
t
)
->
bool
{
ret
t1
==
t2
;
}
let
eq
=
bind
compare_rec
(
_
,
_
);
let
eq
=
compare_rec
(
_
,
_
);
test_generic
::
<
t
>
({
a
:
1
,
b
:
2
},
{
a
:
2
,
b
:
3
},
eq
);
}
...
...
src/test/run-pass/fixed-point-bind-box.rs
浏览文件 @
b106ef81
fn
fix_help
<
A
,
B
>
(
f
:
native
fn
(
fn
@
(
A
)
->
B
,
A
)
->
B
,
x
:
A
)
->
B
{
ret
f
(
bind
fix_help
(
f
,
_
),
x
);
ret
f
(
fix_help
(
f
,
_
),
x
);
}
fn
fix
<
A
,
B
>
(
f
:
native
fn
(
fn
@
(
A
)
->
B
,
A
)
->
B
)
->
fn
@
(
A
)
->
B
{
ret
bind
fix_help
(
f
,
_
);
ret
fix_help
(
f
,
_
);
}
fn
fact_
(
f
:
fn
@
(
&&
int
)
->
int
,
&&
n
:
int
)
->
int
{
...
...
src/test/run-pass/fixed-point-bind-unique.rs
浏览文件 @
b106ef81
fn
fix_help
<
A
,
B
:
send
>
(
f
:
native
fn
(
fn
@
(
A
)
->
B
,
A
)
->
B
,
x
:
A
)
->
B
{
ret
f
(
bind
fix_help
(
f
,
_
),
x
);
ret
f
(
fix_help
(
f
,
_
),
x
);
}
fn
fix
<
A
,
B
:
send
>
(
f
:
native
fn
(
fn
@
(
A
)
->
B
,
A
)
->
B
)
->
fn
@
(
A
)
->
B
{
ret
bind
fix_help
(
f
,
_
);
ret
fix_help
(
f
,
_
);
}
fn
fact_
(
f
:
fn
@
(
&&
int
)
->
int
,
&&
n
:
int
)
->
int
{
...
...
src/test/run-pass/fun-call-variants.rs
浏览文件 @
b106ef81
...
...
@@ -7,7 +7,7 @@ fn main() {
let
a
:
int
=
direct
(
3
);
// direct
let
b
:
int
=
ho
(
direct
);
// indirect unbound
let
c
:
int
=
ho
(
bind
direct
(
_
));
// indirect bound
let
c
:
int
=
ho
(
direct
(
_
));
// indirect bound
assert
(
a
==
b
);
assert
(
b
==
c
);
}
src/test/run-pass/generic-bind.rs
浏览文件 @
b106ef81
...
...
@@ -6,12 +6,12 @@ fn main() {
let
t
=
{
_0
:
1
,
_1
:
2
,
_2
:
3
,
_3
:
4
,
_4
:
5
,
_5
:
6
,
_6
:
7
};
assert
(
t
._5
==
6
);
let
f1
=
bind
id
::
<
{
_0
:
int
,
_1
:
int
,
_2
:
int
,
_3
:
int
,
_4
:
int
,
_5
:
int
,
_6
:
int
}
>
(
_
);
id
::
<
{
_0
:
int
,
_1
:
int
,
_2
:
int
,
_3
:
int
,
_4
:
int
,
_5
:
int
,
_6
:
int
}
>
(
_
);
assert
(
f1
(
t
)
._5
==
6
);
}
src/test/run-pass/hashmap-memory.rs
浏览文件 @
b106ef81
...
...
@@ -58,7 +58,7 @@ fn emit(im: map::hashmap<str, int>, ctrl: chan<ctrl_proto>, key: str,
}
}
map
(
input
,
bind
emit
(
intermediates
,
ctrl
,
_
,
_
));
map
(
input
,
emit
(
intermediates
,
ctrl
,
_
,
_
));
send
(
ctrl
,
mapper_done
);
}
...
...
src/test/run-pass/issue-333.rs
浏览文件 @
b106ef81
fn
quux
<
T
:
copy
>
(
x
:
T
)
->
T
{
let
f
=
bind
id
::
<
T
>
(
_
);
ret
f
(
x
);
}
fn
quux
<
T
:
copy
>
(
x
:
T
)
->
T
{
let
f
=
id
::
<
T
>
(
_
);
ret
f
(
x
);
}
fn
id
<
T
:
copy
>
(
x
:
T
)
->
T
{
ret
x
;
}
...
...
src/test/run-pass/issue-898.rs
浏览文件 @
b106ef81
...
...
@@ -7,5 +7,5 @@ fn log_if<T>(c: native fn(T)->bool, e: T) {
}
fn
main
()
{
(
bind
log_if
(
even
,
_
))(
2
);
(
log_if
(
even
,
_
))(
2
);
}
src/test/run-pass/rebind-fn.rs
浏览文件 @
b106ef81
fn
add
(
i
:
int
,
j
:
int
)
->
int
{
ret
i
+
j
;
}
fn
binder
(
n
:
int
)
->
fn
@
()
->
int
{
let
f
=
bind
add
(
n
,
_
);
ret
bind
f
(
2
);
}
fn
binder
(
n
:
int
)
->
fn
@
()
->
int
{
let
f
=
add
(
n
,
_
);
ret
bind
f
(
2
);
}
fn
main
()
{
binder
(
5
);
let
f
=
binder
(
1
);
...
...
src/test/run-pass/task-comm-17.rs
浏览文件 @
b106ef81
// xfail-test
// Issue #922
// This test is specifically about spawning temporary closures, which
// isn't possible under the bare-fn regime. I'm keeping it around
// until such time as we have unique closures.
// This test is specifically about spawning temporary closures.
use
std
;
import
task
;
...
...
@@ -12,5 +9,5 @@ fn f() {
}
fn
main
()
{
task
::
spawn
(
bind
f
())
;
task
::
spawn
{||
f
()
}
;
}
\ No newline at end of file
src/test/run-pass/unchecked-predicates.rs
浏览文件 @
b106ef81
...
...
@@ -18,7 +18,7 @@ fn pure_foldl<T: copy, U: copy>(ls: list<T>, u: U, f: fn(T, U) -> U) -> U {
// fn from a pure fn
pure
fn
pure_length
<
T
:
copy
>
(
ls
:
list
<
T
>
)
->
uint
{
fn
count
<
T
>
(
_
t
:
T
,
&&
u
:
uint
)
->
uint
{
u
+
1u
}
unchecked
{
pure_foldl
(
ls
,
0u
,
bind
count
(
_
,
_
))
}
unchecked
{
pure_foldl
(
ls
,
0u
,
count
(
_
,
_
))
}
}
pure
fn
nonempty_list
<
T
:
copy
>
(
ls
:
list
<
T
>
)
->
bool
{
pure_length
(
ls
)
>
0u
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录