]> git.lizzy.rs Git - rust.git/blob - tests/ui/unboxed-closures/unboxed-closures-infer-fnonce-move.rs
Auto merge of #107054 - petrochenkov:effvisdoc3, r=GuillaumeGomez
[rust.git] / tests / ui / unboxed-closures / unboxed-closures-infer-fnonce-move.rs
1 // run-pass
2 // Test that we are able to infer a suitable kind for this `move`
3 // closure that is just called (`FnOnce`).
4
5 use std::mem;
6
7 struct DropMe<'a>(&'a mut i32);
8
9 impl<'a> Drop for DropMe<'a> {
10     fn drop(&mut self) {
11         *self.0 += 1;
12     }
13 }
14
15 fn main() {
16     let mut counter = 0;
17
18     {
19         let drop_me = DropMe(&mut counter);
20         let tick = move || mem::drop(drop_me);
21         tick();
22     }
23
24     assert_eq!(counter, 1);
25 }