Skip to content

Commit 257dbb8

Browse files
authored
Rollup merge of rust-lang#59880 - solson:transmute-float, r=alexcrichton
Remove note about transmute for float bitpatterns. This particular usecase has been safely abstracted in these `std` functions: [f32::to_bits](https://doc.rust-lang.org/std/primitive.f32.html#method.to_bits), [f32::from_bits](https://doc.rust-lang.org/std/primitive.f32.html#method.from_bits), [f64::to_bits](https://doc.rust-lang.org/std/primitive.f64.html#method.to_bits), [f64::from_bits](https://doc.rust-lang.org/std/primitive.f64.html#method.from_bits). So, I think we shouldn't recommend an unnecessary use of `unsafe` here anymore.
2 parents ef90d94 + f54df44 commit 257dbb8

File tree

1 file changed

+0
-10
lines changed

1 file changed

+0
-10
lines changed

src/libcore/intrinsics.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -737,16 +737,6 @@ extern "rust-intrinsic" {
737737
///
738738
/// There are a few things that `transmute` is really useful for.
739739
///
740-
/// Getting the bitpattern of a floating point type (or, more generally,
741-
/// type punning, when `T` and `U` aren't pointers):
742-
///
743-
/// ```
744-
/// let bitpattern = unsafe {
745-
/// std::mem::transmute::<f32, u32>(1.0)
746-
/// };
747-
/// assert_eq!(bitpattern, 0x3F800000);
748-
/// ```
749-
///
750740
/// Turning a pointer into a function pointer. This is *not* portable to
751741
/// machines where function pointers and data pointers have different sizes.
752742
///

0 commit comments

Comments
 (0)