]> git.lizzy.rs Git - rust.git/blobdiff - src/libcollections/str.rs
auto merge of #15271 : jasonthompson/rust/docs/str, r=huonw
[rust.git] / src / libcollections / str.rs
index 10309adef20d9faafa8c8de2d610b66e30eeef9e..7e47f02d21a0ce043546bd51281c19b03026fec6 100644 (file)
@@ -106,6 +106,14 @@ pub fn from_utf8_owned(vv: Vec<u8>) -> Result<String, Vec<u8>> {
 /// # Failure
 ///
 /// Fails if invalid UTF-8
+///
+/// # Example
+///
+/// ```rust
+/// use std::str;
+/// let string = str::from_byte(66u8);
+/// assert_eq!(string.as_slice(), "B");
+/// ```
 pub fn from_byte(b: u8) -> String {
     assert!(b < 128u8);
     String::from_char(1, b as char)