pub enum Compare {
Int,
Float,
Bool,
Str,
Identity,
Tag,
}Expand description
What a comparison compares.
Variants§
Int
Float
Bool
Str
The bytes of two crate::Shape::Str objects.
Identity
Two words, as words.
This is is: the identity comparison the language reserves for
shared storage, and it is the one comparison that is allowed to look
at a reference as bits, because that is what it is asking about.
Tag
Two case indices, as the integers they are.
Inst::Tag says a tag is refused by arithmetic, ordering and
integer comparison, because none of those accepts that Repr — and
that refusal is what keeps a case index from being confused with a
number. This does not weaken it: it accepts a Tag and nothing else,
so the pairing a tag can take part in is still only with another tag.
What it is for is Kind.Space == Kind.Word, which is 1 == 2. An
enum with no payload is one word wide and that word is the
discriminant, so two of them are equal exactly when the two words are.
Walked instead by Any.equals, the same question measured 342 ms
against 210 for 2,000,000 comparisons — 66 ns of builtin call apiece,
and 8% of a native profile of a formatter that reads a token’s kind in
every loop it has.
Trait Implementations§
impl Copy for Compare
impl Eq for Compare
impl StructuralPartialEq for Compare
Auto Trait Implementations§
impl Freeze for Compare
impl RefUnwindSafe for Compare
impl Send for Compare
impl Sync for Compare
impl Unpin for Compare
impl UnsafeUnpin for Compare
impl UnwindSafe for Compare
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.