We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent efa3ec6 commit b8e0989Copy full SHA for b8e0989
src/liballoc/str.rs
@@ -855,6 +855,19 @@ impl str {
855
}
856
857
/// Returns an iterator of `u16` over the string encoded as UTF-16.
858
+ ///
859
+ /// # Examples
860
861
+ /// Basic usage:
862
863
+ /// ```
864
+ /// let text = "Zażółć gęślą jaźń";
865
866
+ /// let utf8_len = text.len();
867
+ /// let utf16_len = text.encode_utf16().count();
868
869
+ /// assert!(utf16_len <= utf8_len);
870
871
#[stable(feature = "encode_utf16", since = "1.8.0")]
872
pub fn encode_utf16(&self) -> EncodeUtf16 {
873
EncodeUtf16 { encoder: Utf16Encoder::new(self[..].chars()) }
0 commit comments