diff options
| author | Pietro Albini <pietro@pietroalbini.org> | 2018-10-25 14:31:07 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-25 14:31:07 +0200 |
| commit | f740b8a4de449ff4aa1c7ca9c7fda53a4ee5d313 (patch) | |
| tree | 7a41ea2e428a3a990026cdef1fe2fde938ed3fe0 /src/libstd/primitive_docs.rs | |
| parent | c4e51a2c5240073677e00d6f5c7340221d5acfc3 (diff) | |
| parent | 0f6e2741f692add6d1995b630e2073d18aa2b2ba (diff) | |
| download | rust-f740b8a4de449ff4aa1c7ca9c7fda53a4ee5d313.tar.gz rust-f740b8a4de449ff4aa1c7ca9c7fda53a4ee5d313.zip | |
Rollup merge of #55247 - peterjoel:peterjoel-prim-char-doc-example, r=joshtriplett
Clarified code example in char primitive doc 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 elements in the slice by the item size. This change demonstrates the idea more straightforwardly, without needing a calculation, by just comparing the size of the slices.
Diffstat (limited to 'src/libstd/primitive_docs.rs')
| -rw-r--r-- | src/libstd/primitive_docs.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index 3b432d05132..c2a16122a0d 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -323,8 +323,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 { } |
