Rehabilitate an unboxed closure test
This test works as a regression test for issue #17655. It also exercises mutation of by-ref upvars.
This commit is contained in:
parent
c4c19fe960
commit
39344c2d7e
1 changed files with 2 additions and 7 deletions
|
@ -8,13 +8,9 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// ignore-test
|
|
||||||
//
|
|
||||||
// This is ignored because it depends on #16122.
|
|
||||||
|
|
||||||
#![feature(overloaded_calls, unboxed_closures)]
|
#![feature(overloaded_calls, unboxed_closures)]
|
||||||
|
|
||||||
fn each<'a,T,F:|&mut: &'a T|>(x: &'a [T], mut f: F) {
|
fn each<'a,T,F:FnMut(&'a T)>(x: &'a [T], mut f: F) {
|
||||||
for val in x.iter() {
|
for val in x.iter() {
|
||||||
f(val)
|
f(val)
|
||||||
}
|
}
|
||||||
|
@ -23,7 +19,6 @@ fn each<'a,T,F:|&mut: &'a T|>(x: &'a [T], mut f: F) {
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut sum = 0u;
|
let mut sum = 0u;
|
||||||
let elems = [ 1u, 2, 3, 4, 5 ];
|
let elems = [ 1u, 2, 3, 4, 5 ];
|
||||||
each(elems, ref |&mut: val: &uint| sum += *val);
|
each(elems, |&mut: val: &uint| sum += *val);
|
||||||
assert_eq!(sum, 15);
|
assert_eq!(sum, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue