Skip to content

Instantly share code, notes, and snippets.

@bvssvni
Last active January 4, 2016 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bvssvni/8633182 to your computer and use it in GitHub Desktop.
Save bvssvni/8633182 to your computer and use it in GitHub Desktop.
#[inline]
fn as_ref<'a, T: 'static>(a: &'a Entity) -> Option<&'a T> {
if TypeId::of::<T>() == TypeId::of::<&'static Entity>() {
Some(unsafe { transmute(a.as_void_ptr()) })
} else {
None
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment