use generic params for arc_new_cyclic
This commit is contained in:
parent
ef472f1dc9
commit
ce31cbc7a3
2 changed files with 8 additions and 2 deletions
|
@ -415,7 +415,10 @@ impl<T> Rc<T> {
|
||||||
/// [`upgrade`]: Weak::upgrade
|
/// [`upgrade`]: Weak::upgrade
|
||||||
#[cfg(not(no_global_oom_handling))]
|
#[cfg(not(no_global_oom_handling))]
|
||||||
#[stable(feature = "arc_new_cyclic", since = "1.59.0")]
|
#[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
|
// Construct the inner in the "uninitialized" state with a single
|
||||||
// weak reference.
|
// weak reference.
|
||||||
let uninit_ptr: NonNull<_> = Box::leak(box RcBox {
|
let uninit_ptr: NonNull<_> = Box::leak(box RcBox {
|
||||||
|
|
|
@ -392,7 +392,10 @@ impl<T> Arc<T> {
|
||||||
#[cfg(not(no_global_oom_handling))]
|
#[cfg(not(no_global_oom_handling))]
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "arc_new_cyclic", since = "1.59.0")]
|
#[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
|
// Construct the inner in the "uninitialized" state with a single
|
||||||
// weak reference.
|
// weak reference.
|
||||||
let uninit_ptr: NonNull<_> = Box::leak(box ArcInner {
|
let uninit_ptr: NonNull<_> = Box::leak(box ArcInner {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue