File tree 1 file changed +6
-3
lines changed
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -414,17 +414,20 @@ pub const fn needs_drop<T>() -> bool {
414
414
intrinsics:: needs_drop :: < T > ( )
415
415
}
416
416
417
- /// Creates a value whose bytes are all zero.
417
+ /// Returns the value of type `T` represented by the all- zero byte-pattern .
418
418
///
419
- /// This has the same effect as [`MaybeUninit::zeroed().assume_init()`][zeroed].
420
- /// It is useful for FFI sometimes, but should generally be avoided .
419
+ /// This means that, for example, the padding byte in `(u8, u16)` is not
420
+ /// necessarily zeroed .
421
421
///
422
422
/// There is no guarantee that an all-zero byte-pattern represents a valid value of
423
423
/// some type `T`. For example, the all-zero byte-pattern is not a valid value
424
424
/// for reference types (`&T` and `&mut T`). Using `zeroed` on such types
425
425
/// causes immediate [undefined behavior][ub] because [the Rust compiler assumes][inv]
426
426
/// that there always is a valid value in a variable it considers initialized.
427
427
///
428
+ /// This has the same effect as [`MaybeUninit::zeroed().assume_init()`][zeroed].
429
+ /// It is useful for FFI sometimes, but should generally be avoided.
430
+ ///
428
431
/// [zeroed]: union.MaybeUninit.html#method.zeroed
429
432
/// [ub]: ../../reference/behavior-considered-undefined.html
430
433
/// [inv]: union.MaybeUninit.html#initialization-invariant
You can’t perform that action at this time.
0 commit comments