]> git.lizzy.rs Git - rust.git/commitdiff
librand: Remove all uses of `~str` from `librand`
authorPatrick Walton <pcwalton@mimiga.net>
Tue, 13 May 2014 21:38:13 +0000 (14:38 -0700)
committerPatrick Walton <pcwalton@mimiga.net>
Thu, 15 May 2014 01:29:13 +0000 (18:29 -0700)
src/librand/lib.rs
src/libregex/test/bench.rs
src/libstd/os.rs

index 1f0dd9a407e2b84117e660e32c628307419e03cd..5b71d5c4da722c34c3b3a9b58acf8274040731b6 100644 (file)
@@ -260,7 +260,7 @@ fn gen_weighted_bool(&mut self, n: uint) -> bool {
     ///
     /// 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\
                                                              abcdefghijklmnopqrstuvwxyz\
                                                              0123456789");
@@ -268,7 +268,7 @@ fn gen_ascii_str(&mut self, len: uint) -> ~str {
         for _ in range(0, len) {
             s.push_char(self.choose(GEN_ASCII_STR_CHARSET) as char)
         }
-        s.into_owned()
+        s
     }
 
     /// Choose an item randomly, failing if `values` is empty.
index 3630e0ebb5c8e5b666cdbe2a167b094d823350ae..4c4ba8dd6bf93e133db10fa4b8208cd85cf5cbed 100644 (file)
@@ -159,7 +159,7 @@ fn gen_text(n: uint) -> StrBuf {
             *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)
index 0a920a275acc4c575237521270041bd559cd9446..88081d90b40013d55c8e37acb74e118e65659de7 100644 (file)
@@ -1511,9 +1511,9 @@ pub fn test_args() {
 
     fn make_rand_name() -> ~str {
         let mut rng = rand::task_rng();
-        let n = "TEST".to_owned() + rng.gen_ascii_str(10u);
-        assert!(getenv(n).is_none());
-        n
+        let n = format_strbuf!("TEST{}", rng.gen_ascii_str(10u).as_slice());
+        assert!(getenv(n.as_slice()).is_none());
+        n.into_owned()
     }
 
     #[test]