Skip to content

Commit

Permalink
Add explanation of the hack
Browse files Browse the repository at this point in the history
  • Loading branch information
aumetra committed Aug 27, 2024
1 parent 9a4bebe commit 07515c2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/cw-schema/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ impl Identifier {
T: ?Sized,
{
// Don't do this at home. I'm a professional.
//
// This is a hack based on the assumption that each type has will produce a unique monomorphized function.
// Therefore each function has a distinct function pointer.
//
// The compiler _might_ break this assumption in the future.
#[inline]
fn type_id_of<T: ?Sized>() -> usize {
type_id_of::<T> as usize
Expand Down

0 comments on commit 07515c2

Please sign in to comment.