diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 434084d3af865..17ec325e257b0 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -146,6 +146,7 @@ use clone::Clone; use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering}; +use convert::From; use default::Default; use fmt::{self, Debug, Display}; use marker::{Copy, PhantomData, Send, Sync, Sized, Unsize}; @@ -329,6 +330,13 @@ impl Ord for Cell { } } +#[stable(feature = "cell_from", since = "1.12.0")] +impl From for Cell { + fn from(t: T) -> Cell { + Cell::new(t) + } +} + /// A mutable memory location with dynamically checked borrow rules /// /// See the [module-level documentation](index.html) for more. @@ -742,6 +750,13 @@ impl Ord for RefCell { } } +#[stable(feature = "cell_from", since = "1.12.0")] +impl From for RefCell { + fn from(t: T) -> RefCell { + RefCell::new(t) + } +} + struct BorrowRef<'b> { borrow: &'b Cell, } @@ -1064,3 +1079,10 @@ impl Default for UnsafeCell { UnsafeCell::new(Default::default()) } } + +#[stable(feature = "cell_from", since = "1.12.0")] +impl From for UnsafeCell { + fn from(t: T) -> UnsafeCell { + UnsafeCell::new(t) + } +}