[][src]Struct hexchat::SafeLazy

pub struct SafeLazy<T> where
    T: 'static, 
{ /* fields omitted */ }

A lazily-evaluated resource that is safe to use in a HexChat plugin.

It is recommended that you not use any other kind of static resource crate, because any static resource will not get dropped when your plugin is unloaded, leading to a memory leak if the resource contains a heap allocation. This includes thread_local!, lazy_static, once_cell, etc. It's not the crate that matters, it's the heap resource.

Any SafeLazys will be initialized the first time you use it, and will be dropped after your plugin is dropped.

A SafeLazy must always be in a static variable. To do otherwise is undefined.

Important

Any thread which accesses a safe static, mutex or no, must be killed inside your plugin's Drop implementation. To allow otherwise is undefined.

Trait Implementations

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

type Target = T

The resulting type after dereferencing.

impl<T> Sync for SafeLazy<T> where
    T: Send + Sync
[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for SafeLazy<T>

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

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

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

Blanket Implementations

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

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

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

impl<T> Erased for T

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

impl<T, U> Into<U> for T where
    U: From<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.