Comparable

Trait Comparable 

Source
pub trait Comparable: 'static {
    // Required methods
    unsafe fn equal(&self, other: *const u8) -> bool;
    unsafe fn less_than(&self, other: *const u8) -> bool;
    unsafe fn compare(&self, other: *const u8) -> Ordering;
}
Expand description

An object-safe verson of comparison traits.

Traits like Eq and Ord are not object-safe since they take a reference to Self as the second argument. This trait is an object-safe (but runtime-unsafe) version of Eq and Ord , which takes the second argument as a *const u8. It is meant to only be used inside the (private) derive_comparison_traits macro to derive Ord and Eq for trait objects.

Required Methods§

Source

unsafe fn equal(&self, other: *const u8) -> bool

Test if self and other are equal.

§Safety

other must be a valid reference to a value of type Self.

Source

unsafe fn less_than(&self, other: *const u8) -> bool

Returns true iff self < other.

§Safety

other must be a valid reference to a value of type Self.

Source

unsafe fn compare(&self, other: *const u8) -> Ordering

Compare self with other.

§Safety

other must be a valid reference to a value of type Self.

Implementors§

Source§

impl<T> Comparable for T
where T: Ord + Eq + 'static,