Skip to content

Commit 90ab2f8

Browse files
committed
auto merge of #15271 : jasonthompson/rust/docs/str, r=huonw
I'm working on adding examples to the API documentation. Should future pull requests include examples for more than one function? Or is this about the right size for a pull request?
2 parents db29e1b + 0bfcfcf commit 90ab2f8

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)