Skip to content

Commit 7abf6f1

Browse files
committed
librand: Remove all uses of ~str from librand
1 parent 6415d06 commit 7abf6f1

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/librand/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,15 +260,15 @@ pub trait Rng {
260260
///
261261
/// println!("{}", task_rng().gen_ascii_str(10));
262262
/// ```
263-
fn gen_ascii_str(&mut self, len: uint) -> ~str {
263+
fn gen_ascii_str(&mut self, len: uint) -> StrBuf {
264264
static GEN_ASCII_STR_CHARSET: &'static [u8] = bytes!("ABCDEFGHIJKLMNOPQRSTUVWXYZ\
265265
abcdefghijklmnopqrstuvwxyz\
266266
0123456789");
267267
let mut s = StrBuf::with_capacity(len);
268268
for _ in range(0, len) {
269269
s.push_char(self.choose(GEN_ASCII_STR_CHARSET) as char)
270270
}
271-
s.into_owned()
271+
s
272272
}
273273

274274
/// Choose an item randomly, failing if `values` is empty.

src/libregex/test/bench.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ fn gen_text(n: uint) -> StrBuf {
159159
*b = '\n' as u8
160160
}
161161
}
162-
str::from_utf8(bytes).unwrap().to_strbuf()
162+
str::from_utf8(bytes.as_slice()).unwrap().to_strbuf()
163163
}
164164

165165
throughput!(easy0_32, easy0(), 32)

src/libstd/os.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,9 +1511,9 @@ mod tests {
15111511

15121512
fn make_rand_name() -> ~str {
15131513
let mut rng = rand::task_rng();
1514-
let n = "TEST".to_owned() + rng.gen_ascii_str(10u);
1515-
assert!(getenv(n).is_none());
1516-
n
1514+
let n = format_strbuf!("TEST{}", rng.gen_ascii_str(10u).as_slice());
1515+
assert!(getenv(n.as_slice()).is_none());
1516+
n.into_owned()
15171517
}
15181518

15191519
#[test]

0 commit comments

Comments
 (0)