mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 20:46:07 +03:00
add tests I forgot to add
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
// error-pattern: copying a noncopyable value
|
||||
|
||||
fn to_lambda1(f: lambda(uint) -> uint) -> lambda(uint) -> uint {
|
||||
ret f;
|
||||
}
|
||||
|
||||
fn to_lambda2(b: block(uint) -> uint) -> lambda(uint) -> uint {
|
||||
ret to_lambda1({|x| b(x)});
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fn to_lambda(f: lambda(uint) -> uint) -> lambda(uint) -> uint {
|
||||
ret f;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x: lambda(uint) -> uint = to_lambda({ |x| x * 2u });
|
||||
let y = to_lambda(x);
|
||||
|
||||
let x_r = x(22u);
|
||||
let y_r = y(x_r);
|
||||
|
||||
assert x_r == 44u;
|
||||
assert y_r == 88u;
|
||||
}
|
||||
Reference in New Issue
Block a user