Skip to content

Commit 655aa92

Browse files
committed
Add tests for adding Fn impl to Arc
1 parent e0cffea commit 655aa92

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

library/alloc/src/sync/tests.rs

+15
Original file line numberDiff line numberDiff line change
@@ -618,3 +618,18 @@ fn test_arc_cyclic_two_refs() {
618618
assert_eq!(Arc::strong_count(&two_refs), 3);
619619
assert_eq!(Arc::weak_count(&two_refs), 2);
620620
}
621+
622+
#[test]
623+
fn test_arc_fn() {
624+
let f = || String::from("hello");
625+
let f: Arc<dyn Fn() -> String> = Arc::new(f);
626+
627+
assert_eq!(quox(&f), "hello");
628+
}
629+
630+
fn quox<F>(f: &F) -> String
631+
where
632+
F: Fn() -> String,
633+
{
634+
f()
635+
}

0 commit comments

Comments
 (0)