pub enum HashableValue {
None,
Bool(bool),
I64(i64),
Int(BigInt),
F64(f64),
Bytes(Vec<u8>),
String(String),
Tuple(Vec<HashableValue>),
FrozenSet(BTreeSet<HashableValue>),
}Expand description
Represents all primitive builtin Python values that can be contained in a “hashable” context (i.e., as dictionary keys and set elements).
In Rust, the type is not hashable, since we use B-tree maps and sets instead of the hash variants. To be able to put all Value instances into these B-trees, we implement a consistent ordering between all the possible types (see below).
Variants§
None
None
Bool(bool)
Boolean
I64(i64)
Short integer
Int(BigInt)
Long integer
F64(f64)
Float
Bytes(Vec<u8>)
Bytestring
String(String)
Unicode string
Tuple(Vec<HashableValue>)
Tuple
FrozenSet(BTreeSet<HashableValue>)
Frozen (immutable) set
Implementations§
Source§impl HashableValue
impl HashableValue
Sourcepub fn into_value(self) -> Value
pub fn into_value(self) -> Value
Convert the value into its non-hashable version. This always works.
Trait Implementations§
Source§impl Clone for HashableValue
impl Clone for HashableValue
Source§fn clone(&self) -> HashableValue
fn clone(&self) -> HashableValue
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HashableValue
impl Debug for HashableValue
Source§impl<'de> Deserialize<'de> for HashableValue
impl<'de> Deserialize<'de> for HashableValue
Source§fn deserialize<D: Deserializer<'de>>(
deser: D,
) -> StdResult<HashableValue, D::Error>
fn deserialize<D: Deserializer<'de>>( deser: D, ) -> StdResult<HashableValue, D::Error>
Source§impl Display for HashableValue
impl Display for HashableValue
Source§impl Ord for HashableValue
Implement a (more or less) consistent ordering for HashableValues
so that they can be added to dictionaries and sets.
impl Ord for HashableValue
Implement a (more or less) consistent ordering for HashableValues
so that they can be added to dictionaries and sets.
Also, like in Python, numeric values with the same value (integral or not) must compare equal.
For other types, we define an ordering between all types A and B so that all objects of type A are always lesser than objects of type B. This is done similar to Python 2’s ordering of different types.