|
1 | 1 | //! A heterogeneous collection to store property values. |
2 | | -use core::mem::transmute; |
| 2 | +use core::{any::TypeId, mem::transmute}; |
3 | 3 |
|
4 | 4 | /// A heterogeneous collection to store property values. |
5 | 5 | #[const_trait] |
@@ -88,40 +88,3 @@ mod private { |
88 | 88 | impl<Head: 'static, Tail: ~const Bag> const Sealed for super::List<Head, Tail> {} |
89 | 89 | impl<Left: ~const Bag, Right: ~const Bag> const Sealed for super::Either<Left, Right> {} |
90 | 90 | } |
91 | | - |
92 | | -// `TypeId` doesn't implement `const PartialEq` [ref:type_id_partial_eq] |
93 | | -/// A wrapper of [`core::any::TypeId`] that is usable in a constant context. |
94 | | -struct TypeId { |
95 | | - inner: core::any::TypeId, |
96 | | -} |
97 | | - |
98 | | -impl TypeId { |
99 | | - #[inline] |
100 | | - const fn of<T: 'static>() -> Self { |
101 | | - Self { |
102 | | - inner: core::any::TypeId::of::<T>(), |
103 | | - } |
104 | | - } |
105 | | - |
106 | | - #[inline] |
107 | | - const fn eq(&self, other: &Self) -> bool { |
108 | | - // This relies on the implementation details of `TypeId`, but I think |
109 | | - // we're are okay judging by the fact that WebRender is doing the same |
110 | | - // <https://github.com/rust-lang/rust/pull/75923#issuecomment-683090745> |
111 | | - unsafe { |
112 | | - type TypeIdBytes = [u8; core::mem::size_of::<core::any::TypeId>()]; |
113 | | - let x: TypeIdBytes = transmute(self.inner); |
114 | | - let y: TypeIdBytes = transmute(other.inner); |
115 | | - // Can't just do `x == y` due to [ref:array_const_partial_eq]. |
116 | | - // A non-idiomatic loop must be used due to [ref:const_for]. |
117 | | - let mut i = 0; |
118 | | - while i < x.len() { |
119 | | - if x[i] != y[i] { |
120 | | - return false; |
121 | | - } |
122 | | - i += 1; |
123 | | - } |
124 | | - true |
125 | | - } |
126 | | - } |
127 | | -} |
0 commit comments