Skip to content

Commit 4fbc80b

Browse files
committed
Add explanation of the hack
1 parent 9a4bebe commit 4fbc80b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/cw-schema/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,17 @@ impl Identifier {
153153
T: ?Sized,
154154
{
155155
// Don't do this at home. I'm a professional.
156+
//
157+
// This is a hack based on the assumption that each type has will produce a unique monomorphized function.
158+
// Therefore each function has a distinct function pointer.
159+
//
160+
// The compiler _might_ break this assumption in the future.
156161
#[inline]
157162
fn type_id_of<T: ?Sized>() -> usize {
158163
type_id_of::<T> as usize
159164
}
160165

161166
debug_assert_eq!(type_id_of::<T>(), type_id_of::<T>());
162-
debug_assert_eq!(core::any::type_name::<T>(), core::any::type_name::<T>());
163167

164168
Self(type_id_of::<T>())
165169
}

0 commit comments

Comments
 (0)