pub enum MapKey {
Int(i32),
Str(Arc<str>),
Bool(bool),
}Expand description
A scalar key for a Value::Map.
v1 permits int, string, and bool keys (value-model-spec §4). Keys are
compared for equality only — never hashed or sorted — because a
Value::Map iterates in insertion order. Two keys of different variants
are never equal (an Int(1) key and a Bool(true) key are distinct).
Variants§
Implementations§
Source§impl MapKey
impl MapKey
Sourcepub fn from_value(value: &Value) -> Option<Self>
pub fn from_value(value: &Value) -> Option<Self>
Derive a map key from a scalar Value, or None if the value is not
one of the permitted key types (int/string/bool).
This is the seam the collection opcodes (T1b) use to turn an indexing operand into a key; keeping it here keeps the permitted key domain in one place.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for MapKey
impl<'de> Deserialize<'de> for MapKey
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for MapKey
impl StructuralPartialEq for MapKey
Auto Trait Implementations§
impl Freeze for MapKey
impl RefUnwindSafe for MapKey
impl Send for MapKey
impl Sync for MapKey
impl Unpin for MapKey
impl UnsafeUnpin for MapKey
impl UnwindSafe for MapKey
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