From 60ce31a00c533b5fe54a50893c30712d3b677f06 Mon Sep 17 00:00:00 2001 From: tormol Date: Tue, 23 Feb 2016 05:55:49 +0100 Subject: [PATCH 1/2] Correct char.encode_utf16() documentation The "A buffer that's too small" example was calling encode_utf8(). --- src/librustc_unicode/char.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_unicode/char.rs b/src/librustc_unicode/char.rs index a489b4991f4b6..20f4687f2f429 100644 --- a/src/librustc_unicode/char.rs +++ b/src/librustc_unicode/char.rs @@ -476,7 +476,7 @@ impl char { /// /// let mut b = [0; 0]; /// - /// let result = 'ß'.encode_utf8(&mut b); + /// let result = 'ß'.encode_utf16(&mut b); /// /// assert_eq!(result, None); /// ``` From d34c6eeed49acb227bbd07db9d321319cec5dd56 Mon Sep 17 00:00:00 2001 From: tormol Date: Wed, 24 Feb 2016 06:27:00 +0100 Subject: [PATCH 2/2] Use a character that requires two `u16`s in the examples for `char.encode_utf16()` --- src/librustc_unicode/char.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/librustc_unicode/char.rs b/src/librustc_unicode/char.rs index 20f4687f2f429..115002867555d 100644 --- a/src/librustc_unicode/char.rs +++ b/src/librustc_unicode/char.rs @@ -457,16 +457,16 @@ impl char { /// /// # Examples /// - /// In both of these examples, 'ß' takes one `u16` to encode. + /// In both of these examples, '𝕊' takes two `u16`s to encode. /// /// ``` /// #![feature(unicode)] /// - /// let mut b = [0; 1]; + /// let mut b = [0; 2]; /// - /// let result = 'ß'.encode_utf16(&mut b); + /// let result = '𝕊'.encode_utf16(&mut b); /// - /// assert_eq!(result, Some(1)); + /// assert_eq!(result, Some(2)); /// ``` /// /// A buffer that's too small: @@ -474,9 +474,9 @@ impl char { /// ``` /// #![feature(unicode)] /// - /// let mut b = [0; 0]; + /// let mut b = [0; 1]; /// - /// let result = 'ß'.encode_utf16(&mut b); + /// let result = '𝕊'.encode_utf16(&mut b); /// /// assert_eq!(result, None); /// ```