summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-02-04 22:55:47 +0000
committerbors <bors@rust-lang.org>2016-02-04 22:55:47 +0000
commit9d8e3a024aec4985927687b19cbb1077a09022c2 (patch)
tree72747f78437db08317a8f4810b269d448ad55599 /src/libstd
parentc007e4a010e30db1c92bb3cd5157ffa8282dbbd6 (diff)
parent96d866a19db6ff21bcd0549f455437689e4237e2 (diff)
downloadrust-9d8e3a024aec4985927687b19cbb1077a09022c2.tar.gz
rust-9d8e3a024aec4985927687b19cbb1077a09022c2.zip
Auto merge of #31416 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #31007, #31396, #31401, #31411, #31412, #31413, #31415
- Failed merges:
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/ascii.rs21
-rw-r--r--src/libstd/collections/hash/map.rs6
2 files changed, 24 insertions, 3 deletions
diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs
index b6123264ea8..38f79079b29 100644
--- a/src/libstd/ascii.rs
+++ b/src/libstd/ascii.rs
@@ -18,6 +18,27 @@ use mem;
 use ops::Range;
 
 /// Extension methods for ASCII-subset only operations on string slices.
+///
+/// Be aware that operations on seemingly non-ASCII characters can sometimes
+/// have unexpected results. Consider this example:
+///
+/// ```
+/// use std::ascii::AsciiExt;
+///
+/// assert_eq!("café".to_ascii_uppercase(), "CAFÉ");
+/// assert_eq!("café".to_ascii_uppercase(), "CAFé");
+/// ```
+///
+/// In the first example, the lowercased string is represented `"cafe\u{301}"`
+/// (the last character is an acute accent [combining character]). Unlike the
+/// other characters in the string, the combining character will not get mapped
+/// to an uppercase variant, resulting in `"CAFE\u{301}"`. In the second
+/// example, the lowercased string is represented `"caf\u{e9}"` (the last
+/// character is a single Unicode character representing an 'e' with an acute
+/// accent). Since the last character is defined outside the scope of ASCII,
+/// it will not get mapped to an uppercase variant, resulting in `"CAF\u{e9}"`.
+///
+/// [combining character]: https://en.wikipedia.org/wiki/Combining_character
 #[stable(feature = "rust1", since = "1.0.0")]
 pub trait AsciiExt {
     /// Container type for copied ASCII characters.
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs
index 7ce4aa07b50..f8efada9f6c 100644
--- a/src/libstd/collections/hash/map.rs
+++ b/src/libstd/collections/hash/map.rs
@@ -282,9 +282,9 @@ fn test_resize_policy() {
 /// let mut player_stats = HashMap::new();
 ///
 /// fn random_stat_buff() -> u8 {
-///   // could actually return some random value here - let's just return
-///   // some fixed value for now
-///   42
+///     // could actually return some random value here - let's just return
+///     // some fixed value for now
+///     42
 /// }
 ///
 /// // insert a key only if it doesn't already exist