Handle

Struct Handle 

Source
pub struct Handle { /* private fields */ }
Expand description

Handle is a one-time token for inserting values into DeferredMap

Handle does not implement the Clone trait, ensuring it can only be used once through Rust’s move semantics.

Handle 是一次性令牌,用于向 DeferredMap 插入值

Handle 不实现 Clone trait,通过 Rust 的 move semantics 确保只能使用一次

§Examples (示例)

use deferred_map::DeferredMap;
 
let mut map = DeferredMap::new();
let handle = map.allocate_handle();
let key = handle.key();
map.insert(handle, 42).unwrap();
assert_eq!(map.get(key), Some(&42));

Implementations§

Source§

impl Handle

Source

pub fn key(&self) -> u64

Get the key that will be used for this handle

This is the same as raw_value(), but with a more semantic name.

获取此 handle 对应的 key

这与 raw_value() 相同,但名称更具语义性

Source

pub fn index(&self) -> u32

Extract index (lower 32 bits)

提取 index(低 32 位)

Source

pub fn generation(&self) -> u32

Extract generation (upper 32 bits)

提取 generation(高 32 位)

Trait Implementations§

Source§

impl Debug for Handle

Source§

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

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

impl PartialEq for Handle

Source§

fn eq(&self, other: &Handle) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Handle

Source§

impl StructuralPartialEq for Handle

Auto Trait Implementations§

§

impl Freeze for Handle

§

impl RefUnwindSafe for Handle

§

impl Send for Handle

§

impl Sync for Handle

§

impl Unpin for Handle

§

impl UnwindSafe for Handle

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> 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, 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.