@@ -602,7 +602,7 @@ impl dyn Any + Send + Sync { |
|
|
602 |
602 |
/// While `TypeId` implements `Hash`, `PartialOrd`, and `Ord`, it is worth |
603 |
603 |
/// noting that the hashes and ordering will vary between Rust releases. Beware |
604 |
604 |
/// of relying on them inside of your code! |
605 |
|
-#[derive(Clone, Copy, Debug, Eq, PartialOrd, Ord)] |
|
605 |
+#[derive(Clone, Copy, Eq, PartialOrd, Ord)] |
606 |
606 |
#[stable(feature = "rust1", since = "1.0.0")] |
607 |
607 |
pub struct TypeId { |
608 |
608 |
// We avoid using `u128` because that imposes higher alignment requirements on many platforms. |
@@ -644,6 +644,10 @@ impl TypeId { |
|
|
644 |
644 |
let t2 = t as u64; |
645 |
645 |
TypeId { t: (t1, t2) } |
646 |
646 |
} |
|
647 |
+ |
|
648 |
+fn as_u128(self) -> u128 { |
|
649 |
+ u128::from(self.t.0) << 64 | u128::from(self.t.1) |
|
650 |
+} |
647 |
651 |
} |
648 |
652 |
|
649 |
653 |
#[stable(feature = "rust1", since = "1.0.0")] |
@@ -666,6 +670,13 @@ impl hash::Hash for TypeId { |
|
|
666 |
670 |
} |
667 |
671 |
} |
668 |
672 |
|
|
673 |
+#[stable(feature = "rust1", since = "1.0.0")] |
|
674 |
+impl fmt::Debug for TypeId { |
|
675 |
+fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { |
|
676 |
+ f.debug_tuple("TypeId").field(&self.as_u128()).finish() |
|
677 |
+} |
|
678 |
+} |
|
679 |
+ |
669 |
680 |
/// Returns the name of a type as a string slice. |
670 |
681 |
/// |
671 |
682 |
/// # Note |