Skip to content

Commit

Permalink
Deprecate str::from_byte
Browse files Browse the repository at this point in the history
Replaced by `String::from_byte`

[breaking-change]
  • Loading branch information
aochagavia committed Jul 15, 2014
1 parent 05baf9b commit 173baac
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion src/libcollections/string.rs
Expand Up @@ -91,7 +91,7 @@ impl String {
Err(vec)
}
}

/// Convert a vector of chars to a string
///
/// # Example
Expand Down Expand Up @@ -137,6 +137,23 @@ impl 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) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-fail/glob-use-std.rs
Expand Up @@ -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")
}

0 comments on commit 173baac

Please sign in to comment.