libstd: Make a temporary separate stage0
implementation for Cell
to
avoid a crash in later stages
This commit is contained in:
parent
d40974a5fe
commit
07dc0f3a74
@ -21,6 +21,33 @@ pub struct Cell<T> {
|
||||
priv value: T,
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<T> Cell<T> {
|
||||
/// Creates a new `Cell` containing the given value.
|
||||
pub fn new(value: T) -> Cell<T> {
|
||||
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<T: ::kinds::Pod> Cell<T> {
|
||||
/// Creates a new `Cell` containing the given value.
|
||||
pub fn new(value: T) -> Cell<T> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user