## StableOrd

# Trait StableOrd

Source

    pub trait StableOrd: Ord {
        const CAN_USE_UNSTABLE_SORT: bool;
        const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: ();
    }

Expand description

Trait for marking a type as having a sort order that is stable across compilation session boundaries. More formally:

    Ord::cmp(a1, b1) == Ord::cmp(a2, b2)
       where a2 = decode(encode(a1, context1), context2)
             b2 = decode(encode(b1, context1), context2)

i.e. the result of `Ord::cmp` is not influenced by encoding the values in one session and then decoding them in another session.

This is trivially true for types where encoding and decoding don’t change the bytes of the values that are used during comparison and comparison only depends on these bytes (as opposed to some non-local state). Examples are u32, String, Path, etc.

But it is not true for:

- `*const T` and `*mut T` because the values of these pointers will change between sessions.
- `DefIndex`, `CrateNum`, `LocalDefId`, because their concrete values depend on state that might be different between compilation sessions.

The associated constant `CAN_USE_UNSTABLE_SORT` denotes whether unstable sorting can be used for this type. Set to true if and only if `a == b` implies `a` and `b` are fully indistinguishable.

## Required Associated Constants§

Source

#### const CAN_USE_UNSTABLE_SORT: bool

Source

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: ()

Marker to ensure that implementors have carefully considered whether their `Ord` implementation obeys this trait’s contract.

## Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

## Implementations on Foreign Types§

Source§

### impl StableOrd for &str

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for bool

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for char

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for i8

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for i16

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for i32

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for i64

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for i128

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for isize

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for u8

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for u16

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for u32

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for u64

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for u128

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for ()

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for usize

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for Hash64

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for Hash128

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for String

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for OsStr

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for Path

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl StableOrd for PathBuf

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl<T1: StableOrd, T2: StableOrd> StableOrd for (T1, T2)

Source§

#### const CAN_USE_UNSTABLE_SORT: bool

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl<T1: StableOrd, T2: StableOrd, T3: StableOrd> StableOrd for (T1, T2, T3)

Source§

#### const CAN_USE_UNSTABLE_SORT: bool

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl<T1: StableOrd, T2: StableOrd, T3: StableOrd, T4: StableOrd> StableOrd for (T1, T2, T3, T4)

Source§

#### const CAN_USE_UNSTABLE_SORT: bool

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl<T: StableOrd> StableOrd for Option<T>

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = T::CAN_USE_UNSTABLE_SORT

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

Source§

### impl<T: StableOrd> StableOrd for &T

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = T::CAN_USE_UNSTABLE_SORT

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()

## Implementors§

Source§

### impl StableOrd for Fingerprint

Source§

#### const CAN_USE_UNSTABLE_SORT: bool = true

Source§

#### const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ()