Skip to content

Commit 0bfcfcf

Browse files
committed
add example for from_byte() documenation
1 parent 04da31e commit 0bfcfcf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libcollections/str.rs

+8
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ pub fn from_utf8_owned(vv: Vec<u8>) -> Result<String, Vec<u8>> {
106106
/// # Failure
107107
///
108108
/// Fails if invalid UTF-8
109+
///
110+
/// # Example
111+
///
112+
/// ```rust
113+
/// use std::str;
114+
/// let string = str::from_byte(66u8);
115+
/// assert_eq!(string.as_slice(), "B");
116+
/// ```
109117
pub fn from_byte(b: u8) -> String {
110118
assert!(b < 128u8);
111119
String::from_char(1, b as char)

0 commit comments

Comments
 (0)