about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-10-16 22:36:06 +0200
committerGitHub <noreply@github.com>2022-10-16 22:36:06 +0200
commitbdfc2627421f6393acc7fce493ba5dd56e947bb0 (patch)
tree3b94c97b8e53b784d0434c529615944f89ab90a2
parent2c0bfbed4334e8c91168c1b7ed0dd3807fce6486 (diff)
parenta6372525ce40611b21764b261cf27a288df2d825 (diff)
downloadrust-bdfc2627421f6393acc7fce493ba5dd56e947bb0.tar.gz
rust-bdfc2627421f6393acc7fce493ba5dd56e947bb0.zip
Rollup merge of #103102 - H4x5:len_utf16_docs, r=scottmcm
Clarify the possible return values of `len_utf16`

`char::len_utf16` always return 1 or 2. Clarify this in the docs, in the same way as `char::len_utf8`.
-rw-r--r--library/core/src/char/methods.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/library/core/src/char/methods.rs b/library/core/src/char/methods.rs
index 224bc9effe6..bb83599369c 100644
--- a/library/core/src/char/methods.rs
+++ b/library/core/src/char/methods.rs
@@ -597,9 +597,14 @@ impl char {
     /// Returns the number of 16-bit code units this `char` would need if
     /// encoded in UTF-16.
     ///
+    /// That number of code units is always either 1 or 2, for unicode scalar values in
+    /// the [basic multilingual plane] or [supplementary planes] respectively.
+    ///
     /// See the documentation for [`len_utf8()`] for more explanation of this
     /// concept. This function is a mirror, but for UTF-16 instead of UTF-8.
     ///
+    /// [basic multilingual plane]: http://www.unicode.org/glossary/#basic_multilingual_plane
+    /// [supplementary planes]: http://www.unicode.org/glossary/#supplementary_planes
     /// [`len_utf8()`]: #method.len_utf8
     ///
     /// # Examples