Skip to content

Commit

Permalink
Rollup merge of rust-lang#55247 - peterjoel:peterjoel-prim-char-doc-e…
Browse files Browse the repository at this point in the history
…xample, 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.
  • Loading branch information
kennytm committed Oct 24, 2018
2 parents 2eff59f + 0f6e274 commit 7f06f15
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libstd/primitive_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
Expand Down

0 comments on commit 7f06f15

Please sign in to comment.