Implement CoerceUnsized for {Cell, RefCell, UnsafeCell}
This commit is contained in:
parent
13ff307f07
commit
1fd791ad62
1 changed files with 16 additions and 0 deletions
|
|
@ -337,6 +337,9 @@ impl<T: Copy> From<T> for Cell<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "coerce_unsized", issue = "27732")]
|
||||
impl<T: CoerceUnsized<U>, U> CoerceUnsized<Cell<U>> for Cell<T> {}
|
||||
|
||||
/// A mutable memory location with dynamically checked borrow rules
|
||||
///
|
||||
/// See the [module-level documentation](index.html) for more.
|
||||
|
|
@ -757,6 +760,9 @@ impl<T> From<T> for RefCell<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "coerce_unsized", issue = "27732")]
|
||||
impl<T: CoerceUnsized<U>, U> CoerceUnsized<RefCell<U>> for RefCell<T> {}
|
||||
|
||||
struct BorrowRef<'b> {
|
||||
borrow: &'b Cell<BorrowFlag>,
|
||||
}
|
||||
|
|
@ -1086,3 +1092,13 @@ impl<T> From<T> for UnsafeCell<T> {
|
|||
UnsafeCell::new(t)
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "coerce_unsized", issue = "27732")]
|
||||
impl<T: CoerceUnsized<U>, U> CoerceUnsized<UnsafeCell<U>> for UnsafeCell<T> {}
|
||||
|
||||
#[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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue