macro_rules! hold_my_beer {
    ($something_potentially_bad:expr) => { ... };
}
Expand description

Do you want to do something that the haters would probably say is “foolish” or “reckless”? Just tell the compiler to hold your beer for you as you prove the haters wrong!

#[derive(Debug, PartialEq)]
#[repr(u32)]
enum AmazingEnum {
    One = 1,
    FortyTwo = 42,
    // TODO: Other very important numbers
}

impl From<u32> for AmazingEnum {
    fn from(val: u32) -> Self {
        // Is taking untrusted input dangerous? Maybe.
        hold_my_beer!(std::mem::transmute(val))
    }
}

assert_eq!(AmazingEnum::FortyTwo, AmazingEnum::from(42));