pub enum KeyPart {
Bytes(Vec<u8>),
String(String),
Int(BigInt),
Float(f64),
False,
True,
}
Expand description
A key part is single item in a key. It can be a boolean, a double float, a variable precision signed integer, a UTF-8 string, or an arbitrary byte array.
The ordering of a KeyPart is dependent on the type of the KeyPart.
Between different types, the ordering is as follows: arbitrary byte array < UTF-8 string < variable precision signed integer < double float < false < true.
Within a type, the ordering is as follows:
- For a boolean, false is less than true.
- For a double float, the ordering must follow -NaN < -Infinity < -100.0 < -1.0 < -0.5 < -0.0 < 0.0 < 0.5 < 1.0 < 100.0 < Infinity < NaN.
- For a variable precision signed integer, the ordering must follow mathematical ordering.
- For a UTF-8 string, the ordering must follow the UTF-8 byte ordering.
- For an arbitrary byte array, the ordering must follow the byte ordering.
This means that the key part 1.0
is less than the key part 2.0
, but is
greater than the key part 0n
, because 1.0
is a double float and 0n
is a variable precision signed integer, and the ordering types obviously has
precedence over the ordering within a type.
Variants§
Trait Implementations§
source§impl Ord for KeyPart
impl Ord for KeyPart
source§impl PartialEq<KeyPart> for KeyPart
impl PartialEq<KeyPart> for KeyPart
source§impl PartialOrd<KeyPart> for KeyPart
impl PartialOrd<KeyPart> for KeyPart
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for KeyPart
Auto Trait Implementations§
impl RefUnwindSafe for KeyPart
impl Send for KeyPart
impl Sync for KeyPart
impl Unpin for KeyPart
impl UnwindSafe for KeyPart
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
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.