pub fn replace(&self, val: T, journal: &Journal<A>) -> T {
        // SAFETY: This can cause data races if called from a separate thread,
        // but `PCell` is `!Sync` so this won't happen.

        self.create_log(journal);

        #[cfg(any(feature = "use_pspd", feature = "use_vspd"))] {
            if let Some(tmp) = *self.temp {
                mem::replace(unsafe { &mut *tmp }, val)
            } else {
                mem::replace(unsafe { &mut *self.value.get() }, val)
            }
        }

        #[cfg(not(any(feature = "use_pspd", feature = "use_vspd")))]
        mem::replace(unsafe { &mut (*self.value.get()).1 }, val)
    }
/// Replaces the contained value, and returns it.
///
/// # Examples
///
/// ```
/// use corundum::alloc::heap::*;
/// use corundum::boxed::Pbox;
/// use corundum::cell::PCell;
///
/// Heap::transaction(|j| {
///     let cell = Pbox::new(PCell::new(5), j);
///     assert_eq!(cell.get(), 5);
///     assert_eq!(cell.replace(10, j), 5);
///     assert_eq!(cell.get(), 10);
/// }).unwrap();
/// ```
Replaces the contained value, and returns it.
Replaces the contained value and returns it .
pub fn replace(&self, val: T, journal: &Journal<A>) -> T {
        // SAFETY: This can cause data races if called from a separate thread,
        // but `PCell` is `!Sync` so this won't happen.
        self.create_log(journal);
        #[cfg(any(feature = "use_pspd", feature = "use_vspd"))] {
            if let Some(tmp) = *self.temp {
                mem::replace(unsafe { &mut *tmp }, val)
            } else {
                mem::replace(unsafe { &mut *self.value.get() }, val)
            }
        }
        #[cfg(not(any(feature = "use_pspd", feature = "use_vspd")))]
        mem::replace(unsafe { &mut (*self.value.get()).1 }, val)
    }
pub fn replace ( & self , val : T , journal : & Journal < A > ) -> T { // SAFETY: This can cause data races if called from a separate thread, // but `PCell` is `!Sync` so this won't happen. self . create_log ( journal ) ; # [ cfg ( any ( feature " " feature " " ) ) ] { if let Some ( tmp ) = * self . temp { mem :: replace ( unsafe { & mut * tmp } , val ) } else { mem :: replace ( unsafe { & mut * self . value . get ( ) } , val ) } } # [ cfg ( not ( any ( feature " " feature " " ) ) ) ] mem :: replace ( unsafe { & mut ( * self . value . get ( ) ) . 1 } , val ) }
Replaces the contained value, and returns it.
Replaces the contained value and returns it .
&self
val
T
journal
&Journal<A>
examples
```
use corundum::alloc::heap::*;
use corundum::boxed::Pbox;
use corundum::cell::PCell.


` ` ` use corundum :: alloc :: heap :: * ; use corundum :: boxed :: Pbox ; use corundum :: cell :: PCell .