2012-12-11 01:32:48 +00:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2012-09-12 00:46:20 +00:00
|
|
|
extern mod std;
|
2011-12-30 04:07:55 +00:00
|
|
|
|
2012-01-11 17:58:05 +00:00
|
|
|
fn asSendfn( f : fn~()->uint ) -> uint {
|
2012-08-02 00:30:05 +00:00
|
|
|
return f();
|
2011-12-30 04:07:55 +00:00
|
|
|
}
|
|
|
|
|
2012-01-10 00:12:37 +00:00
|
|
|
fn asLambda( f : fn@()->uint ) -> uint {
|
2012-08-02 00:30:05 +00:00
|
|
|
return f();
|
2011-12-30 04:07:55 +00:00
|
|
|
}
|
|
|
|
|
2012-01-23 22:59:00 +00:00
|
|
|
fn asBlock( f : fn&()->uint ) -> uint {
|
2012-08-02 00:30:05 +00:00
|
|
|
return f();
|
2012-01-23 22:59:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn asAny( f : fn()->uint ) -> uint {
|
2012-08-02 00:30:05 +00:00
|
|
|
return f();
|
2011-12-30 04:07:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2012-06-30 23:19:07 +00:00
|
|
|
let x = asSendfn(|| 22u);
|
2011-12-30 04:07:55 +00:00
|
|
|
assert(x == 22u);
|
2012-06-30 23:19:07 +00:00
|
|
|
let x = asLambda(|| 22u);
|
2011-12-30 04:07:55 +00:00
|
|
|
assert(x == 22u);
|
2012-06-30 23:19:07 +00:00
|
|
|
let x = asBlock(|| 22u);
|
2011-12-30 04:07:55 +00:00
|
|
|
assert(x == 22u);
|
|
|
|
}
|