[][src]Struct dirty_static::DirtyStatic

pub struct DirtyStatic<T>(_);

A container for a value which allows interior mutation only in debug mode. (Or when enabled via force-dynamic feature.)

Methods

impl<T> DirtyStatic<T>[src]

pub const fn new(t: T) -> Self[src]

Create a new DirtyStatic with the given interior value.

Examples

use dirty_static::DirtyStatic;

let c = DirtyStatic::new(100);
assert_eq!(*c, 100);

pub unsafe fn replace(&self, t: T)[src]

Replace the interior value of the DirtyStatic. Note that this will do nothing unless running in debug mode, or enabling the force-dynamic feature.

Examples

// In debug mode
use dirty_static::DirtyStatic;

let c = DirtyStatic::new(100);
unsafe {
    c.replace(200);
}

assert_eq!(*c, 200);
// In release mode
use dirty_static::DirtyStatic;

let c = DirtyStatic::new(100);
unsafe {
    c.replace(200);
}

assert_eq!(*c, 100);

Trait Implementations

impl<T> Sync for DirtyStatic<T> where
    T: Sync
[src]

impl<T> Deref for DirtyStatic<T>[src]

type Target = T

The resulting type after dereferencing.

Auto Trait Implementations

impl<T> Send for DirtyStatic<T> where
    T: Send

impl<T> Unpin for DirtyStatic<T> where
    T: Unpin

impl<T> UnwindSafe for DirtyStatic<T> where
    T: UnwindSafe

impl<T> !RefUnwindSafe for DirtyStatic<T>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]