2014-11-02 11:44:15 -08:00
|
|
|
// Copyright 2014 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.
|
|
|
|
|
2014-11-15 19:10:22 -05:00
|
|
|
#![feature(unboxed_closures)]
|
2014-11-02 11:44:15 -08:00
|
|
|
|
2014-12-22 09:04:23 -08:00
|
|
|
use std::ops::Add;
|
|
|
|
|
2014-11-02 11:44:15 -08:00
|
|
|
#[inline]
|
2015-03-25 17:06:52 -07:00
|
|
|
pub fn has_closures() -> usize {
|
2015-03-03 10:42:26 +02:00
|
|
|
let x = 1;
|
2015-02-01 12:44:15 -05:00
|
|
|
let mut f = move || x;
|
2015-03-03 10:42:26 +02:00
|
|
|
let y = 1;
|
2015-02-01 12:44:15 -05:00
|
|
|
let g = || y;
|
2014-11-02 11:44:15 -08:00
|
|
|
f() + g()
|
|
|
|
}
|
|
|
|
|
2014-12-31 15:45:13 -05:00
|
|
|
pub fn has_generic_closures<T: Add<Output=T> + Copy>(x: T, y: T) -> T {
|
2015-02-01 12:44:15 -05:00
|
|
|
let mut f = move || x;
|
|
|
|
let g = || y;
|
2014-11-02 11:44:15 -08:00
|
|
|
f() + g()
|
|
|
|
}
|