Skip to main content

FlagRef

Struct FlagRef 

Source
pub struct FlagRef<T>(/* private fields */);
Expand description

从FlagCell产生的轻量共享引用,可Clone,单线程使用

Implementations§

Source§

impl<T> FlagRef<T>

Source

pub const EMPTY: Self

空指针实例

Source

pub fn ref_count(&self) -> isize

Source

pub fn is_enabled(&self) -> bool

Source

pub unsafe fn enable(&self) -> FlagRefOption<()>

强制将数据逻辑启用

§SAFETY

本方法为逻辑不安全操作:无内存未定义行为、无 panic 风险。 暴露此方法是为了满足特定场景的便捷性需求。

此方法会虚构出一个 FlagCell ,可能造成其他相关类型功能异常。

Source

pub unsafe fn disable(&self) -> FlagRefOption<()>

强制将数据逻辑禁用

§SAFETY

本方法为逻辑不安全操作:无内存未定义行为、无 panic 风险。 暴露此方法是为了满足特定场景的便捷性需求。

此方法会强制 RefCell 失效,可能造成其他相关类型功能异常。

Source

pub fn try_borrow(&self) -> FlagRefOption<Ref<'_, T>>

尝试借用内部值。

详见 FlagRefOption

Source

pub fn try_borrow_mut(&self) -> FlagRefOption<RefMut<'_, T>>

尝试可变借用内部值。

详见 FlagRefOption

Source

pub fn resurrect(&self) -> FlagRefOption<FlagCell<T>>

尝试复活 FlagCell

仅当前对应 FlagCell 销毁即数据逻辑禁用时,可复活,否则返回 Disabled

Source

pub fn new() -> Self

创建一个不指向任何内容的 FlagRef

尝试调用任何方法都将返回 Empty

Trait Implementations§

Source§

impl<T> Clone for FlagRef<T>

Source§

fn clone(&self) -> Self

克隆一个 FlagRef,使引用计数加一

1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for FlagRef<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for FlagRef<T>

Source§

fn default() -> Self

创建一个不指向任何内容的 FlagRef

尝试调用任何方法都将返回 Empty

Source§

impl<T> Drop for FlagRef<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for FlagRef<T>

§

impl<T> !RefUnwindSafe for FlagRef<T>

§

impl<T> !Send for FlagRef<T>

§

impl<T> !Sync for FlagRef<T>

§

impl<T> Unpin for FlagRef<T>

§

impl<T> UnsafeUnpin for FlagRef<T>

§

impl<T> !UnwindSafe for FlagRef<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.