File tree Expand file tree Collapse file tree 3 files changed +6
-6
lines changed Expand file tree Collapse file tree 3 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -260,15 +260,15 @@ pub trait Rng {
260
260
///
261
261
/// println!("{}", task_rng().gen_ascii_str(10));
262
262
/// ```
263
- fn gen_ascii_str ( & mut self , len : uint ) -> ~ str {
263
+ fn gen_ascii_str ( & mut self , len : uint ) -> StrBuf {
264
264
static GEN_ASCII_STR_CHARSET : & ' static [ u8 ] = bytes ! ( "ABCDEFGHIJKLMNOPQRSTUVWXYZ\
265
265
abcdefghijklmnopqrstuvwxyz\
266
266
0123456789") ;
267
267
let mut s = StrBuf :: with_capacity ( len) ;
268
268
for _ in range ( 0 , len) {
269
269
s. push_char ( self . choose ( GEN_ASCII_STR_CHARSET ) as char )
270
270
}
271
- s. into_owned ( )
271
+ s
272
272
}
273
273
274
274
/// Choose an item randomly, failing if `values` is empty.
Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ fn gen_text(n: uint) -> StrBuf {
159
159
* b = '\n' as u8
160
160
}
161
161
}
162
- str:: from_utf8 ( bytes) . unwrap ( ) . to_strbuf ( )
162
+ str:: from_utf8 ( bytes. as_slice ( ) ) . unwrap ( ) . to_strbuf ( )
163
163
}
164
164
165
165
throughput ! ( easy0_32, easy0( ) , 32 )
Original file line number Diff line number Diff line change @@ -1511,9 +1511,9 @@ mod tests {
1511
1511
1512
1512
fn make_rand_name ( ) -> ~str {
1513
1513
let mut rng = rand:: task_rng ( ) ;
1514
- let n = "TEST" . to_owned ( ) + rng. gen_ascii_str ( 10 u) ;
1515
- assert ! ( getenv( n) . is_none( ) ) ;
1516
- n
1514
+ let n = format_strbuf ! ( "TEST{}" , rng. gen_ascii_str( 10 u) . as_slice ( ) ) ;
1515
+ assert ! ( getenv( n. as_slice ( ) ) . is_none( ) ) ;
1516
+ n. into_owned ( )
1517
1517
}
1518
1518
1519
1519
#[ test]
You can’t perform that action at this time.
0 commit comments