Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #![feature(maybe_uninit)]
  2.  
  3. pub mod foo {
  4. #[derive(Debug)]
  5. pub struct Spartacus { _reserved: () }
  6.  
  7. impl Spartacus {
  8. /// # Safety
  9. ///
  10. /// There can be only one.
  11. pub unsafe fn new_unchecked() -> Spartacus {
  12. Spartacus { _reserved: () }
  13. }
  14. }
  15. }
  16.  
  17. use core::mem::MaybeUninit;
  18. use foo::Spartacus;
  19.  
  20. fn main() {
  21. let spartacus = unsafe { Spartacus::new_unchecked() };
  22. let imposter: Spartacus = unsafe { MaybeUninit::uninitialized().into_initialized() };
  23. println!("{:?}", (spartacus, imposter));
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement