Macro safety_breaker::force_convert [−][src]
macro_rules! force_convert { ($x:expr, $y:ty) => { ... }; }
Changes the type of a reference to another type
Example
#[macro_use] extern crate safety_breaker; fn main() { let a: u32 = 65; //In ASCII, 65 (decimal) means 'A'. unsafe { let b = force_convert!(&a, char); //b is &char println!("{}", b); //'A' will be displayed. } }
How to use
The first argument is a reference to the variable which you want to change its type. The second argument is the type of the conversion target. This macro must be used in an unsafe block. This macro can also be used to change the type parameters and the lifetime annotations