Rollup merge of #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.
This commit is contained in:
commit
257dbb826d
1 changed files with 0 additions and 10 deletions
|
|
@ -737,16 +737,6 @@ extern "rust-intrinsic" {
|
|||
///
|
||||
/// There are a few things that `transmute` is really useful for.
|
||||
///
|
||||
/// Getting the bitpattern of a floating point type (or, more generally,
|
||||
/// type punning, when `T` and `U` aren't pointers):
|
||||
///
|
||||
/// ```
|
||||
/// let bitpattern = unsafe {
|
||||
/// std::mem::transmute::<f32, u32>(1.0)
|
||||
/// };
|
||||
/// assert_eq!(bitpattern, 0x3F800000);
|
||||
/// ```
|
||||
///
|
||||
/// Turning a pointer into a function pointer. This is *not* portable to
|
||||
/// machines where function pointers and data pointers have different sizes.
|
||||
///
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue