File tree 1 file changed +8
-16
lines changed
1 file changed +8
-16
lines changed Original file line number Diff line number Diff line change 1
- // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1
+ // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2
2
// file at the top-level directory of this distribution and at
3
3
// http://rust-lang.org/COPYRIGHT.
4
4
//
@@ -19,26 +19,18 @@ use core::str;
19
19
20
20
pub fn mkdtemp ( tmpdir : & Path , suffix : & str ) -> Option < Path > {
21
21
let r = rand:: Rng ( ) ;
22
- let mut i = 0 u;
23
- while ( i < 1000 u) {
24
- let p = tmpdir. push ( r. gen_str ( 16 u) +
25
- str:: from_slice ( suffix) ) ;
26
- if os:: make_dir ( & p, 0x1c0i32 ) { // FIXME: u+rwx (#2349)
22
+ for 1000 . times {
23
+ let p = tmpdir. push( r. gen_str( 16 ) + suffix) ;
24
+ if os:: make_dir( & p, 0x1c0 ) { // 700
27
25
return Some ( p) ;
28
26
}
29
- i += 1 u;
30
27
}
31
- return None ;
28
+ None
32
29
}
33
30
34
31
#[ test]
35
32
fn test_mkdtemp( ) {
36
- let r = mkdtemp ( & Path ( "." ) , "foobar" ) ;
37
- match r {
38
- Some ( ref p) => {
39
- os:: remove_dir ( p) ;
40
- assert ( str:: ends_with ( p. to_str ( ) , "foobar" ) ) ;
41
- }
42
- _ => assert ( false )
43
- }
33
+ let p = mkdtemp( & Path ( "." ) , "foobar" ) . unwrap( ) ;
34
+ os:: remove_dir( & p) ;
35
+ assert str:: ends_with( p. to_str( ) , "foobar" ) ;
44
36
}
You can’t perform that action at this time.
0 commit comments