Skip to content

Commit c881c23

Browse files
zhassan-awstedinski
authored andcommitted
1 parent 74f7957 commit c881c23

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
// Check that we can pass a FnMut closure to a stand alone
5+
// function definition.
6+
7+
// kani-flags: --unwind 6
8+
9+
fn each<T, F>(x: &[T], mut f: F)
10+
where
11+
F: FnMut(&T),
12+
{
13+
for val in x {
14+
f(val)
15+
}
16+
}
17+
18+
fn main() {
19+
let mut sum = 0_usize;
20+
let elems = [1_usize, 2, 3, 4, 5];
21+
each(&elems, |val| sum += *val);
22+
assert_eq!(sum, 15);
23+
}

0 commit comments

Comments
 (0)