Skip to content

Commit 1fd791a

Browse files
committed
Implement CoerceUnsized for {Cell, RefCell, UnsafeCell}
1 parent 13ff307 commit 1fd791a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: src/libcore/cell.rs

+16
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,9 @@ impl<T: Copy> From<T> for Cell<T> {
337337
}
338338
}
339339

340+
#[unstable(feature = "coerce_unsized", issue = "27732")]
341+
impl<T: CoerceUnsized<U>, U> CoerceUnsized<Cell<U>> for Cell<T> {}
342+
340343
/// A mutable memory location with dynamically checked borrow rules
341344
///
342345
/// See the [module-level documentation](index.html) for more.
@@ -757,6 +760,9 @@ impl<T> From<T> for RefCell<T> {
757760
}
758761
}
759762

763+
#[unstable(feature = "coerce_unsized", issue = "27732")]
764+
impl<T: CoerceUnsized<U>, U> CoerceUnsized<RefCell<U>> for RefCell<T> {}
765+
760766
struct BorrowRef<'b> {
761767
borrow: &'b Cell<BorrowFlag>,
762768
}
@@ -1086,3 +1092,13 @@ impl<T> From<T> for UnsafeCell<T> {
10861092
UnsafeCell::new(t)
10871093
}
10881094
}
1095+
1096+
#[unstable(feature = "coerce_unsized", issue = "27732")]
1097+
impl<T: CoerceUnsized<U>, U> CoerceUnsized<UnsafeCell<U>> for UnsafeCell<T> {}
1098+
1099+
#[allow(unused)]
1100+
fn assert_coerce_unsized(a: UnsafeCell<&i32>, b: Cell<&i32>, c: RefCell<&i32>) {
1101+
let _: UnsafeCell<&Send> = a;
1102+
let _: Cell<&Send> = b;
1103+
let _: RefCell<&Send> = c;
1104+
}

0 commit comments

Comments
 (0)