]> git.lizzy.rs Git - rust.git/commitdiff
test calling Box<dyn FnOnce>
authorRalf Jung <post@ralfj.de>
Sun, 7 Apr 2019 18:05:57 +0000 (20:05 +0200)
committerRalf Jung <post@ralfj.de>
Sun, 7 Apr 2019 18:06:22 +0000 (20:06 +0200)
tests/run-pass/closures.rs

index 9b379051eb774a88f12c75cd18520c89534c9be2..141e6cd6d08a2777f99cf4459b6d034e9802ee4e 100644 (file)
@@ -40,9 +40,14 @@ fn once<F: FnOnce(i64, i64) -> i64>(f: F) -> i64 { f(2, 3) }
     }
 }
 
+fn boxed(f: Box<dyn FnOnce() -> i32>) -> i32 {
+    f()
+}
+
 fn main() {
     assert_eq!(simple(), 12);
     assert_eq!(crazy_closure(), (84, 10, 10));
     assert_eq!(closure_arg_adjustment_problem(), 3);
     assert_eq!(fn_once_closure_with_multiple_args(), 6);
+    assert_eq!(boxed(Box::new({let x = 13; move || x})), 13);
 }