librand: Remove all uses of ~str from librand

This commit is contained in:
Patrick Walton
2014-05-13 14:38:13 -07:00
parent 6415d06616
commit 7abf6f1346
3 changed files with 6 additions and 6 deletions

View File

@@ -260,7 +260,7 @@ pub trait Rng {
/// ///
/// println!("{}", task_rng().gen_ascii_str(10)); /// println!("{}", task_rng().gen_ascii_str(10));
/// ``` /// ```
fn gen_ascii_str(&mut self, len: uint) -> ~str { fn gen_ascii_str(&mut self, len: uint) -> StrBuf {
static GEN_ASCII_STR_CHARSET: &'static [u8] = bytes!("ABCDEFGHIJKLMNOPQRSTUVWXYZ\ static GEN_ASCII_STR_CHARSET: &'static [u8] = bytes!("ABCDEFGHIJKLMNOPQRSTUVWXYZ\
abcdefghijklmnopqrstuvwxyz\ abcdefghijklmnopqrstuvwxyz\
0123456789"); 0123456789");
@@ -268,7 +268,7 @@ pub trait Rng {
for _ in range(0, len) { for _ in range(0, len) {
s.push_char(self.choose(GEN_ASCII_STR_CHARSET) as char) s.push_char(self.choose(GEN_ASCII_STR_CHARSET) as char)
} }
s.into_owned() s
} }
/// Choose an item randomly, failing if `values` is empty. /// Choose an item randomly, failing if `values` is empty.

View File

@@ -159,7 +159,7 @@ fn gen_text(n: uint) -> StrBuf {
*b = '\n' as u8 *b = '\n' as u8
} }
} }
str::from_utf8(bytes).unwrap().to_strbuf() str::from_utf8(bytes.as_slice()).unwrap().to_strbuf()
} }
throughput!(easy0_32, easy0(), 32) throughput!(easy0_32, easy0(), 32)

View File

@@ -1511,9 +1511,9 @@ mod tests {
fn make_rand_name() -> ~str { fn make_rand_name() -> ~str {
let mut rng = rand::task_rng(); let mut rng = rand::task_rng();
let n = "TEST".to_owned() + rng.gen_ascii_str(10u); let n = format_strbuf!("TEST{}", rng.gen_ascii_str(10u).as_slice());
assert!(getenv(n).is_none()); assert!(getenv(n.as_slice()).is_none());
n n.into_owned()
} }
#[test] #[test]