add example for from_byte() documenation

This commit is contained in:
Jason Thompson 2014-06-30 06:38:47 -04:00
parent 04da31e64c
commit 0bfcfcffa7
1 changed files with 8 additions and 0 deletions

View 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)