Clarified code example

The example was not as clear as it could be because it was making an assumption about the structure of the data in order to multiply the number of collection elements by the item size. This change demonstrates the idea more straightforwardly, without the calculation.
This commit is contained in:
Peter Hall 2018-10-21 18:53:09 +01:00 committed by GitHub
parent ef9781358d
commit 0f6e2741f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -322,8 +322,8 @@ mod prim_never { }
/// let s = String::from("love: ❤️");
/// let v: Vec<char> = s.chars().collect();
///
/// assert_eq!(12, s.len() * std::mem::size_of::<u8>());
/// assert_eq!(32, v.len() * std::mem::size_of::<char>());
/// assert_eq!(12, std::mem::size_of_val(&s[..]));
/// assert_eq!(32, std::mem::size_of_val(&v[..]));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
mod prim_char { }