rust/tests/target/closure.rs

67 lines
2.1 KiB
Rust
Raw Normal View History

2015-08-19 15:39:45 -05:00
// Closures
fn main() {
let square = (|i: i32| i * i);
let commented = |// first
a, // argument
// second
b: WithType, // argument
// ignored
_| (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbb);
let commented = |// first
a, // argument
// second
b: WithType, // argument
// ignored
_| {
(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb)
};
let block_body = move |xxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
ref yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy| {
xxxxxxxxxxxxxxxxxxxxxxxxxxxxx + yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
};
let loooooooooooooong_name = |field| {
// TODO(#27): format comments.
if field.node.attrs.len() > 0 {
field.node.attrs[0].span.lo
} else {
field.span.lo
}
};
let block_me = |field| {
if true_story() {
1
} else {
2
}
};
let unblock_me = |trivial| closure();
let empty = |arg| {};
2015-08-20 15:08:51 -05:00
let test = || {
do_something();
do_something_else();
};
2015-08-20 16:05:41 -05:00
let arg_test = |big_argument_name, test123| {
looooooooooooooooooong_function_naaaaaaaaaaaaaaaaame()
};
let arg_test = |big_argument_name, test123| {
looooooooooooooooooong_function_naaaaaaaaaaaaaaaaame()
};
2015-08-20 15:08:51 -05:00
|arg1, arg2, _, _, arg3, arg4| {
let temp = arg4 + arg3;
arg2 * arg1 - temp
}
2015-08-19 15:39:45 -05:00
}