]> git.lizzy.rs Git - rust.git/blob - src/docs/transmute_float_to_int.txt
Auto merge of #9421 - xphoniex:fix-#9420, r=giraffate
[rust.git] / src / docs / transmute_float_to_int.txt
1 ### What it does
2 Checks for transmutes from a float to an integer.
3
4 ### Why is this bad?
5 Transmutes are dangerous and error-prone, whereas `to_bits` is intuitive
6 and safe.
7
8 ### Example
9 ```
10 unsafe {
11     let _: u32 = std::mem::transmute(1f32);
12 }
13
14 // should be:
15 let _: u32 = 1f32.to_bits();
16 ```