From 38c88360510ac6d9c741d7cbc52608908fd21278 Mon Sep 17 00:00:00 2001 From: Taylor Cramer Date: Sun, 1 May 2016 23:30:12 -0700 Subject: [PATCH] docs: Changed docs for `size_of` to describe size as a stride offset Current description of `std::mem::size_of` is ambiguous, and the `std::intrinsics::size_of` description incorrectly defines size as the number of bytes necessary to exactly overwrite a value, not including the padding between elements necessary in a vector or structure. --- src/libcore/intrinsics.rs | 7 ++----- src/libcore/mem.rs | 3 +++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 45890cd3d8139..8a9f662bf83aa 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -192,11 +192,8 @@ extern "rust-intrinsic" { /// The size of a type in bytes. /// - /// This is the exact number of bytes in memory taken up by a - /// value of the given type. In other words, a memset of this size - /// would *exactly* overwrite a value. When laid out in vectors - /// and structures there may be additional padding between - /// elements. + /// More specifically, this is the offset in bytes between successive + /// items of the same type, including alignment padding. pub fn size_of() -> usize; /// Moves a value to an uninitialized memory location. diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 2c648d1516bff..56d268bf37c66 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -117,6 +117,9 @@ pub fn forget(t: T) { /// Returns the size of a type in bytes. /// +/// More specifically, this is the offset in bytes between successive +/// items of the same type, including alignment padding. +/// /// # Examples /// /// ```