diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2016-04-01 18:44:49 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2016-04-02 01:23:23 +0530 |
| commit | cf0a01a161ebbf01230f2e12b7ec8ce9544d4d5f (patch) | |
| tree | 30a2090566bf99231359df78a2df4a96237fbd24 /src/libcore | |
| parent | e004ce1a322739b21960154d6174e41cd9c9666b (diff) | |
| parent | 33db2d65ffd5b988fdedc8ed91b395abaa57f777 (diff) | |
| download | rust-cf0a01a161ebbf01230f2e12b7ec8ce9544d4d5f.tar.gz rust-cf0a01a161ebbf01230f2e12b7ec8ce9544d4d5f.zip | |
Rollup merge of #32652 - VFLashM:refcell_ref_coercion, r=alexcrichton
Added missing refcell ref/refmut coercions to unsized Ref/RefMut should be coercible to unsized. This commit adds a unit test and two missing CoerceUnsized implementations.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/cell.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 4a9a1485063..b2cbc29b1c7 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -147,8 +147,8 @@ use clone::Clone; use cmp::{PartialEq, Eq}; use default::Default; -use marker::{Copy, Send, Sync, Sized}; -use ops::{Deref, DerefMut, Drop, FnOnce}; +use marker::{Copy, Send, Sync, Sized, Unsize}; +use ops::{Deref, DerefMut, Drop, FnOnce, CoerceUnsized}; use option::Option; use option::Option::{None, Some}; @@ -634,6 +634,9 @@ impl<'b, T: ?Sized> Ref<'b, T> { } } +#[unstable(feature = "coerce_unsized", issue = "27732")] +impl<'b, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Ref<'b, U>> for Ref<'b, T> {} + impl<'b, T: ?Sized> RefMut<'b, T> { /// Make a new `RefMut` for a component of the borrowed data, e.g. an enum /// variant. @@ -766,6 +769,9 @@ impl<'b, T: ?Sized> DerefMut for RefMut<'b, T> { } } +#[unstable(feature = "coerce_unsized", issue = "27732")] +impl<'b, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<RefMut<'b, U>> for RefMut<'b, T> {} + /// The core primitive for interior mutability in Rust. /// /// `UnsafeCell<T>` is a type that wraps some `T` and indicates unsafe interior operations on the |
