Skip to content

Commit c56c377

Browse files
committed
Add std::cell::clone_ref back, but deprecated.
1 parent 0c7600e commit c56c377

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/libcore/cell.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,20 @@ impl<'b, T: ?Sized> Deref for Ref<'b, T> {
539539
}
540540
}
541541

542+
/// Copies a `Ref`.
543+
///
544+
/// The `RefCell` is already immutably borrowed, so this cannot fail.
545+
///
546+
/// A `Clone` implementation would interfere with the widespread
547+
/// use of `r.borrow().clone()` to clone the contents of a `RefCell`.
548+
#[deprecated(since = "1.2.0", reason = "moved to a `Ref::clone` associated function")]
549+
#[unstable(feature = "core",
550+
reason = "likely to be moved to a method, pending language changes")]
551+
#[inline]
552+
pub fn clone_ref<'b, T:Clone>(orig: &Ref<'b, T>) -> Ref<'b, T> {
553+
Ref::clone(orig)
554+
}
555+
542556
impl<'b, T: ?Sized> Ref<'b, T> {
543557
/// Copies a `Ref`.
544558
///

0 commit comments

Comments
 (0)