提交 173baac4 编写于 作者: A Adolfo Ochagavía

Deprecate str::from_byte

Replaced by `String::from_byte`

[breaking-change]
上级 05baf9b1
......@@ -137,6 +137,23 @@ pub fn from_char(length: uint, ch: char) -> String {
buf
}
/// Convert a byte to a UTF-8 string
///
/// # Failure
///
/// Fails if invalid UTF-8
///
/// # Example
///
/// ```rust
/// let string = String::from_byte(104);
/// assert_eq!(string.as_slice(), "h");
/// ```
pub fn from_byte(b: u8) -> String {
assert!(b < 128u8);
String::from_char(1, b as char)
}
/// Pushes the given string onto this string buffer.
#[inline]
pub fn push_str(&mut self, string: &str) {
......
......@@ -16,7 +16,7 @@
use std::*;
fn main() {
str::from_byte('a' as u8); // avoid an unused import message
String::from_byte(b'a'); // avoid an unused import message
fail!("fail works")
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册