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:
parent
ef9781358d
commit
0f6e2741f6
@ -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 { }
|
||||
|
Loading…
x
Reference in New Issue
Block a user