pub struct StaticType<T> { /* private fields */ }Expand description
A thread-safe static type wrapper 线程安全的静态类型包装器
Implementations§
Source§impl<T> StaticType<T>
impl<T> StaticType<T>
Sourcepub fn init_call<F: FnOnce() -> T>(&self, call: F)
pub fn init_call<F: FnOnce() -> T>(&self, call: F)
Initialize the value with a closure if not already initialized 如果尚未初始化,则使用闭包初始化值
Sourcepub fn get_or_init<F: FnOnce() -> T>(&self, call: F) -> &T
pub fn get_or_init<F: FnOnce() -> T>(&self, call: F) -> &T
Get the value or initialize it with a closure 获取值或使用闭包初始化它
Sourcepub fn get_static(&self) -> Option<&T>
pub fn get_static(&self) -> Option<&T>
Get the static value (unsafe)
获取静态值(不安全)
this fn not safed; please before use this fn must use init_call or get_or_init
Sourcepub fn get_static_unchecked(&self) -> &T
pub fn get_static_unchecked(&self) -> &T
Get the static value unchecked (unsafe)
获取静态值(不检查,不安全)
this fn not safed; please before use this fn must use init_call or get_or_init
Sourcepub fn get_mut(&self) -> &mut Option<T>
pub fn get_mut(&self) -> &mut Option<T>
Get mutable reference (unsafe)
获取可变引用(不安全)
this fn not safed; please before use this fn must use init_call or get_or_init
Sourcepub fn force_drop(&self) -> Option<T>
pub fn force_drop(&self) -> Option<T>
Force drop the value 强制丢弃值
Trait Implementations§
Source§impl<T> AsRef<T> for StaticType<T>
impl<T> AsRef<T> for StaticType<T>
Source§impl<T: Debug> Debug for StaticType<T>
impl<T: Debug> Debug for StaticType<T>
Source§impl<T: Default> Default for StaticType<T>
impl<T: Default> Default for StaticType<T>
Source§impl<T> Deref for StaticType<T>
impl<T> Deref for StaticType<T>
Source§impl<T> DerefMut for StaticType<T>
impl<T> DerefMut for StaticType<T>
Source§impl<T: Display> Display for StaticType<T>
impl<T: Display> Display for StaticType<T>
impl<T> Send for StaticType<T>
impl<T> Sync for StaticType<T>
Auto Trait Implementations§
impl<T> !Freeze for StaticType<T>
impl<T> !RefUnwindSafe for StaticType<T>
impl<T> Unpin for StaticType<T>where
T: Unpin,
impl<T> UnwindSafe for StaticType<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more