|
146 | 146 |
|
147 | 147 | use clone::Clone;
|
148 | 148 | use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
|
| 149 | +use convert::From; |
149 | 150 | use default::Default;
|
150 | 151 | use fmt::{self, Debug, Display};
|
151 | 152 | use marker::{Copy, PhantomData, Send, Sync, Sized, Unsize};
|
@@ -329,6 +330,13 @@ impl<T:Ord + Copy> Ord for Cell<T> {
|
329 | 330 | }
|
330 | 331 | }
|
331 | 332 |
|
| 333 | +#[stable(feature = "cell_from", since = "1.12.0")] |
| 334 | +impl<T: Copy> From<T> for Cell<T> { |
| 335 | + fn from(t: T) -> Cell<T> { |
| 336 | + Cell::new(t) |
| 337 | + } |
| 338 | +} |
| 339 | + |
332 | 340 | /// A mutable memory location with dynamically checked borrow rules
|
333 | 341 | ///
|
334 | 342 | /// See the [module-level documentation](index.html) for more.
|
@@ -742,6 +750,13 @@ impl<T: ?Sized + Ord> Ord for RefCell<T> {
|
742 | 750 | }
|
743 | 751 | }
|
744 | 752 |
|
| 753 | +#[stable(feature = "cell_from", since = "1.12.0")] |
| 754 | +impl<T> From<T> for RefCell<T> { |
| 755 | + fn from(t: T) -> RefCell<T> { |
| 756 | + RefCell::new(t) |
| 757 | + } |
| 758 | +} |
| 759 | + |
745 | 760 | struct BorrowRef<'b> {
|
746 | 761 | borrow: &'b Cell<BorrowFlag>,
|
747 | 762 | }
|
@@ -1064,3 +1079,10 @@ impl<T: Default> Default for UnsafeCell<T> {
|
1064 | 1079 | UnsafeCell::new(Default::default())
|
1065 | 1080 | }
|
1066 | 1081 | }
|
| 1082 | + |
| 1083 | +#[stable(feature = "cell_from", since = "1.12.0")] |
| 1084 | +impl<T> From<T> for UnsafeCell<T> { |
| 1085 | + fn from(t: T) -> UnsafeCell<T> { |
| 1086 | + UnsafeCell::new(t) |
| 1087 | + } |
| 1088 | +} |
0 commit comments