pub struct Key { /* private fields */ }Expand description
A value used as a dict key or a set member.
Two jobs. It carries the hash, computed once when the key was made, because
a dict asks for it on every lookup and a big tuple would otherwise walk
itself each time. And it gives Rust’s Hash and Eq Python’s meaning
rather than the derived one, so 1, 1.0 and True are one key.
Making one is where an unhashable value is caught, so a Key that exists is
a value that had a hash at the time it was made. Nothing here can change
afterwards, since the only mutable object in the object model is a list and
a list has no hash.
Implementations§
Trait Implementations§
impl Eq for Key
Source§impl FromIterator<Key> for Set
impl FromIterator<Key> for Set
Source§impl PartialEq for Key
impl PartialEq for Key
Auto Trait Implementations§
impl !RefUnwindSafe for Key
impl !Send for Key
impl !Sync for Key
impl !UnwindSafe for Key
impl Freeze for Key
impl Unpin for Key
impl UnsafeUnpin for Key
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