Skip to content

Commit 55013cd

Browse files
committed
Auto merge of #38981 - sdleffler:patch-1, r=alexcrichton
Add PartialOrd, Ord derivations to TypeId I want to be able to sort a `Vec` of types which contain `TypeId`s, so an `Ord` derivation would be very useful to me. `Hash` and `PartialEq`/`Eq` already exist, so the missing `PartialOrd` and `Ord` derivations feel like an oversight to me.
2 parents 61b93bd + b08ab1e commit 55013cd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/libcore/any.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,11 @@ impl Any+Send {
338338
///
339339
/// A `TypeId` is currently only available for types which ascribe to `'static`,
340340
/// but this limitation may be removed in the future.
341-
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
341+
///
342+
/// While `TypeId` implements `Hash`, `PartialOrd`, and `Ord`, it is worth
343+
/// noting that the hashes and ordering will vary between Rust releases. Beware
344+
/// of relying on them outside of your code!
345+
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
342346
#[stable(feature = "rust1", since = "1.0.0")]
343347
pub struct TypeId {
344348
t: u64,

0 commit comments

Comments
 (0)