File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 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 {
414414 intrinsics:: needs_drop :: < T > ( )
415415}
416416
417- /// Creates a value whose bytes are all zero.
417+ /// Returns the value of type `T` represented by the all- zero byte-pattern .
418418///
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 .
421421///
422422/// There is no guarantee that an all-zero byte-pattern represents a valid value of
423423/// some type `T`. For example, the all-zero byte-pattern is not a valid value
424424/// for reference types (`&T` and `&mut T`). Using `zeroed` on such types
425425/// causes immediate [undefined behavior][ub] because [the Rust compiler assumes][inv]
426426/// that there always is a valid value in a variable it considers initialized.
427427///
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+ ///
428431/// [zeroed]: union.MaybeUninit.html#method.zeroed
429432/// [ub]: ../../reference/behavior-considered-undefined.html
430433/// [inv]: union.MaybeUninit.html#initialization-invariant
You can’t perform that action at this time.
0 commit comments