pub struct Handle<K: Key = DefaultKey> { /* 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);
assert_eq!(map.get(key), Some(&42));Implementations§
Source§impl<K: Key> Handle<K>
impl<K: Key> Handle<K>
Sourcepub fn key(&self) -> K
pub fn key(&self) -> K
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() 相同,但名称更具语义性
Sourcepub fn generation(&self) -> Generation
pub fn generation(&self) -> Generation
Extract generation (upper 32 bits)
提取 generation(高 32 位)
Trait Implementations§
impl<K: Eq + Key> Eq for Handle<K>
impl<K: Key> StructuralPartialEq for Handle<K>
Auto Trait Implementations§
impl<K> Freeze for Handle<K>where
K: Freeze,
impl<K> RefUnwindSafe for Handle<K>where
K: RefUnwindSafe,
impl<K> Send for Handle<K>where
K: Send,
impl<K> Sync for Handle<K>where
K: Sync,
impl<K> Unpin for Handle<K>where
K: Unpin,
impl<K> UnwindSafe for Handle<K>where
K: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more