-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Doc clarification for MaybeUninit::zeroed() #111608
Copy link
Copy link
Closed
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsE-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsE-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Location
https://doc.rust-lang.org/std/mem/union.MaybeUninit.html#method.zeroed
Summary
While perhaps implied by the terminology of "memory being filled with 0 bytes", it would be great to explicitly state whether or not padding bytes are included.
For me it's a bit ambiguous because both
std::mem::zeroedandstd::mem::MaybeUninitare parametrized byT. Hence, neither really exposes a concept of "raw" bytes to the user, but just the Rust type. Yet if I compare the above documentation tostd::mem::zeroedit states, among other things:So there padding bytes are explicitly excluded.
It's particularly confusing, because
std::mem::zeroedstates:Should we make it more explicit that
std::mem::MaybeUninit::zeroedalso zeroes out padding bytes? (assuming that's the behavior we want; it seems to be the behavior we currently have)