We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 655aa92 commit 1f60e2fCopy full SHA for 1f60e2f
library/alloc/src/sync/tests.rs
@@ -633,3 +633,25 @@ where
633
{
634
f()
635
}
636
+
637
+#[test]
638
+fn test_arc_fn2() {
639
+ fn apply_fn_once<T>(v: T, f: impl FnOnce(T)) {
640
+ f(v)
641
+ }
642
+ fn apply_fn_mut<T>(v: T, mut f: impl FnMut(T)) {
643
644
645
+ fn apply_fn<T>(v: T, f: impl Fn(T)) {
646
647
648
649
+ let x = Mutex::new(0);
650
+ let f = Arc::new(|v: i32| *x.lock().unwrap() += v);
651
652
+ apply_fn_once(1, f.clone());
653
+ apply_fn_mut(2, f.clone());
654
+ apply_fn(4, f.clone());
655
656
+ assert_eq!(*x.lock().unwrap(), 7);
657
+}
0 commit comments