Skip to content

Instantly share code, notes, and snippets.

@niksaak
Created February 6, 2017 22:49
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 niksaak/23456698c8cca964ece740072a1d041c to your computer and use it in GitHub Desktop.
Save niksaak/23456698c8cca964ece740072a1d041c to your computer and use it in GitHub Desktop.
Well, it's the safety dance.
unsafe fn as_undead<'a, T>(t: &T) -> &'static T {
// I say, we can dance, we can dance
// Everybody look at your hands
&*(t as *const T)
}
unsafe fn as_undead_mut<'a, T>(t: &'mut T) -> &'static mut T {
// We can dance, we can dance
// Everybody's taking the chance
&mut *(t as *mut T)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment