Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![feature(maybe_uninit)]
- pub mod foo {
- #[derive(Debug)]
- pub struct Spartacus { _reserved: () }
- impl Spartacus {
- /// # Safety
- ///
- /// There can be only one.
- pub unsafe fn new_unchecked() -> Spartacus {
- Spartacus { _reserved: () }
- }
- }
- }
- use core::mem::MaybeUninit;
- use foo::Spartacus;
- fn main() {
- let spartacus = unsafe { Spartacus::new_unchecked() };
- let imposter: Spartacus = unsafe { MaybeUninit::uninitialized().into_initialized() };
- println!("{:?}", (spartacus, imposter));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement