Skip to content

Instantly share code, notes, and snippets.

@ArtemGr
Last active March 3, 2025 07:13
Show Gist options
  • Save ArtemGr/ca4bc0433ea3387992f1fa80ac40e6fd to your computer and use it in GitHub Desktop.
Save ArtemGr/ca4bc0433ea3387992f1fa80ac40e6fd to your computer and use it in GitHub Desktop.
maybe0
#![feature(maybe_uninit_as_bytes)] // https://github.com/rust-lang/rust/issues/93092
#![feature(maybe_uninit_slice)]
use std::hint::black_box;
use std::mem::MaybeUninit;
#[unsafe(no_mangle)] pub extern "C" fn maybe0() -> bool {
let str: MaybeUninit<String> = MaybeUninit::zeroed();
unsafe {str.as_bytes().assume_init_ref()} .iter().all (|&b| b == 0)}
#[unsafe(no_mangle)] pub extern "C" fn maybe0black() -> bool {
let str: MaybeUninit<String> = MaybeUninit::zeroed();
unsafe {black_box (str.as_bytes().assume_init_ref())} .iter().all (|&b| b == 0)}
fn main() {let _ = maybe0black();}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment