diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2014-12-28 16:45:56 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2015-01-02 12:09:38 -0500 |
| commit | a535f2aab1eacc757c8c28e87896be12eac56bd1 (patch) | |
| tree | 14741eeec10f89ed2d8bb933355241e15faef395 | |
| parent | dabd7507b66f5ca62bb6e1ab49a572fbb450d8dd (diff) | |
| download | rust-a535f2aab1eacc757c8c28e87896be12eac56bd1.tar.gz rust-a535f2aab1eacc757c8c28e87896be12eac56bd1.zip | |
Test that we can call unboxed closures with the sugar now. Fixes #16929.
| -rw-r--r-- | src/test/run-pass/unboxed-closures-call-sugar-object.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/run-pass/unboxed-closures-call-sugar-object.rs b/src/test/run-pass/unboxed-closures-call-sugar-object.rs new file mode 100644 index 00000000000..2dec53cc13a --- /dev/null +++ b/src/test/run-pass/unboxed-closures-call-sugar-object.rs @@ -0,0 +1,25 @@ +// 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. + +#![feature(unboxed_closures)] + +use std::ops::FnMut; + +fn make_adder(x: int) -> Box<FnMut(int)->int + 'static> { + box move |y| { x + y } +} + +pub fn main() { + let mut adder = make_adder(3); + let z = (*adder)(2); + println!("{}", z); + assert_eq!(z, 5); +} + |
