]> git.lizzy.rs Git - rust.git/commitdiff
docs: Changed docs for `size_of` to describe size as a stride offset
authorTaylor Cramer <cramertj@cs.washington.edu>
Mon, 2 May 2016 06:30:12 +0000 (23:30 -0700)
committerTaylor Cramer <cramertj@cs.washington.edu>
Mon, 2 May 2016 06:38:01 +0000 (23:38 -0700)
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
src/libcore/mem.rs

index 45890cd3d81396a5236ffbf3b5549b955953c5be..8a9f662bf83aa08d537cbf2931e1e0abbb027c8c 100644 (file)
 
     /// 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<T>() -> usize;
 
     /// Moves a value to an uninitialized memory location.
index 2c648d1516bffc30d01aa7e382413544427ff61c..56d268bf37c664100ea8458cf86e4593c96804cf 100644 (file)
@@ -117,6 +117,9 @@ pub fn forget<T>(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
 ///
 /// ```