From 06beef4c6a3ac0dfcc4139f966e0488018fb515c Mon Sep 17 00:00:00 2001 From: Zachary S Date: Fri, 10 May 2024 14:26:38 -0500 Subject: [PATCH] Relax A: Clone requirement on Rc/Arc::unwrap_or_clone. --- library/alloc/src/rc.rs | 2 ++ library/alloc/src/sync.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index 795b12d82bec8..4c54ca36f1ac0 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -1809,7 +1809,9 @@ impl Rc { // reference to the allocation. unsafe { &mut this.ptr.as_mut().value } } +} +impl Rc { /// If we have the only reference to `T` then unwrap it. Otherwise, clone `T` and return the /// clone. /// diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 2b8efdc400bd9..6108caa4a59b4 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -2227,7 +2227,9 @@ impl Arc { // either unique to begin with, or became one upon cloning the contents. unsafe { Self::get_mut_unchecked(this) } } +} +impl Arc { /// If we have the only reference to `T` then unwrap it. Otherwise, clone `T` and return the /// clone. ///