From ce31cbc7a35131d0386f03982d7cac8786f574f4 Mon Sep 17 00:00:00 2001 From: bdbai Date: Thu, 30 Dec 2021 21:55:18 +0800 Subject: [PATCH] use generic params for arc_new_cyclic --- library/alloc/src/rc.rs | 5 ++++- library/alloc/src/sync.rs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index b92fbac36d9..e373be5bb6e 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -415,7 +415,10 @@ impl Rc { /// [`upgrade`]: Weak::upgrade #[cfg(not(no_global_oom_handling))] #[stable(feature = "arc_new_cyclic", since = "1.59.0")] - pub fn new_cyclic(data_fn: impl FnOnce(&Weak) -> T) -> Rc { + pub fn new_cyclic(data_fn: F) -> Rc + where + F: FnOnce(&Weak) -> T, + { // Construct the inner in the "uninitialized" state with a single // weak reference. let uninit_ptr: NonNull<_> = Box::leak(box RcBox { diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 4deec0146e4..aba45f36c15 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -392,7 +392,10 @@ impl Arc { #[cfg(not(no_global_oom_handling))] #[inline] #[stable(feature = "arc_new_cyclic", since = "1.59.0")] - pub fn new_cyclic(data_fn: impl FnOnce(&Weak) -> T) -> Arc { + pub fn new_cyclic(data_fn: F) -> Arc + where + F: FnOnce(&Weak) -> T, + { // Construct the inner in the "uninitialized" state with a single // weak reference. let uninit_ptr: NonNull<_> = Box::leak(box ArcInner {