From 1fd791ad62a4bb901be465997d9efbf4090819f0 Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Fri, 12 Aug 2016 18:10:34 -0400 Subject: [PATCH] Implement `CoerceUnsized` for `{Cell, RefCell, UnsafeCell}` --- src/libcore/cell.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 17ec325e257b0..0a1fe3dbd7730 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -337,6 +337,9 @@ impl From for Cell { } } +#[unstable(feature = "coerce_unsized", issue = "27732")] +impl, U> CoerceUnsized> for Cell {} + /// A mutable memory location with dynamically checked borrow rules /// /// See the [module-level documentation](index.html) for more. @@ -757,6 +760,9 @@ impl From for RefCell { } } +#[unstable(feature = "coerce_unsized", issue = "27732")] +impl, U> CoerceUnsized> for RefCell {} + struct BorrowRef<'b> { borrow: &'b Cell, } @@ -1086,3 +1092,13 @@ impl From for UnsafeCell { UnsafeCell::new(t) } } + +#[unstable(feature = "coerce_unsized", issue = "27732")] +impl, U> CoerceUnsized> for UnsafeCell {} + +#[allow(unused)] +fn assert_coerce_unsized(a: UnsafeCell<&i32>, b: Cell<&i32>, c: RefCell<&i32>) { + let _: UnsafeCell<&Send> = a; + let _: Cell<&Send> = b; + let _: RefCell<&Send> = c; +}