From 07dc0f3a74f3bba5620c91a12320e5bf2773f7b8 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 19 Dec 2013 15:05:16 -0800 Subject: [PATCH] libstd: Make a temporary separate `stage0` implementation for `Cell` to avoid a crash in later stages --- src/libstd/cell.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index 62fc08fd9d3..c5fdddfec76 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -21,6 +21,33 @@ pub struct Cell { priv value: T, } +#[cfg(stage0)] +impl Cell { + /// Creates a new `Cell` containing the given value. + pub fn new(value: T) -> Cell { + Cell { + value: value, + } + } + + /// Returns a copy of the contained value. + #[inline] + pub fn get(&self) -> T { + unsafe { + ::cast::transmute_copy(&self.value) + } + } + + /// Sets the contained value. + #[inline] + pub fn set(&self, value: T) { + unsafe { + *cast::transmute_mut(&self.value) = value + } + } +} + +#[cfg(not(stage0))] impl Cell { /// Creates a new `Cell` containing the given value. pub fn new(value: T) -> Cell {