Skip to content

Commit

Permalink
use generic params for arc_new_cyclic
Browse files Browse the repository at this point in the history
  • Loading branch information
bdbai committed Dec 30, 2021
1 parent ef472f1 commit ce31cbc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion library/alloc/src/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,10 @@ impl<T> Rc<T> {
/// [`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>) -> T) -> Rc<T> {
pub fn new_cyclic<F>(data_fn: F) -> Rc<T>
where
F: FnOnce(&Weak<T>) -> T,
{
// Construct the inner in the "uninitialized" state with a single
// weak reference.
let uninit_ptr: NonNull<_> = Box::leak(box RcBox {
Expand Down
5 changes: 4 additions & 1 deletion library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,10 @@ impl<T> Arc<T> {
#[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>) -> T) -> Arc<T> {
pub fn new_cyclic<F>(data_fn: F) -> Arc<T>
where
F: FnOnce(&Weak<T>) -> T,
{
// Construct the inner in the "uninitialized" state with a single
// weak reference.
let uninit_ptr: NonNull<_> = Box::leak(box ArcInner {
Expand Down

0 comments on commit ce31cbc

Please sign in to comment.