Skip to content

Commit 687b961

Browse files
committed
---
yaml --- r: 124102 b: refs/heads/master c: 173baac h: refs/heads/master v: v3
1 parent 7bada23 commit 687b961

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 05baf9b10c762dd65407ad13e8b1c72e614fd75e
2+
refs/heads/master: 173baac495485848335cf5ffd52fcd4d061d6d50
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: afbcbbc77ffc6b10053bc543daf7d2e05d68cc01
55
refs/heads/try: 296eb104620b346d88bc4a2c2ab7693e6d3db019

trunk/src/libcollections/string.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl String {
9191
Err(vec)
9292
}
9393
}
94-
94+
9595
/// Convert a vector of chars to a string
9696
///
9797
/// # Example
@@ -137,6 +137,23 @@ impl String {
137137
buf
138138
}
139139

140+
/// Convert a byte to a UTF-8 string
141+
///
142+
/// # Failure
143+
///
144+
/// Fails if invalid UTF-8
145+
///
146+
/// # Example
147+
///
148+
/// ```rust
149+
/// let string = String::from_byte(104);
150+
/// assert_eq!(string.as_slice(), "h");
151+
/// ```
152+
pub fn from_byte(b: u8) -> String {
153+
assert!(b < 128u8);
154+
String::from_char(1, b as char)
155+
}
156+
140157
/// Pushes the given string onto this string buffer.
141158
#[inline]
142159
pub fn push_str(&mut self, string: &str) {

trunk/src/test/run-fail/glob-use-std.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use std::*;
1717

1818
fn main() {
19-
str::from_byte('a' as u8); // avoid an unused import message
19+
String::from_byte(b'a'); // avoid an unused import message
2020

2121
fail!("fail works")
2222
}

0 commit comments

Comments
 (0)