about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJason Thompson <jason@jthompson.ca>2014-06-30 06:38:47 -0400
committerJason Thompson <jason@jthompson.ca>2014-06-30 12:30:05 -0400
commit0bfcfcffa7afae00e2371c9e92fae5558ec24c26 (patch)
tree6e2e788fd2e068ce0a6e9e80bbf74721a01d218f
parent04da31e64c983ff49234104b79133d4981ea3314 (diff)
downloadrust-0bfcfcffa7afae00e2371c9e92fae5558ec24c26.tar.gz
rust-0bfcfcffa7afae00e2371c9e92fae5558ec24c26.zip
add example for from_byte() documenation
-rw-r--r--src/libcollections/str.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs
index b5424d1683f..024e8f0f8ee 100644
--- a/src/libcollections/str.rs
+++ b/src/libcollections/str.rs
@@ -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)