File tree Expand file tree Collapse file tree 1 file changed +8
-16
lines changed Expand file tree Collapse file tree 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
22// file at the top-level directory of this distribution and at
33// http://rust-lang.org/COPYRIGHT.
44//
@@ -19,26 +19,18 @@ use core::str;
1919
2020pub fn mkdtemp ( tmpdir : & Path , suffix : & str ) -> Option < Path > {
2121 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
2725 return Some ( p) ;
2826 }
29- i += 1 u;
3027 }
31- return None ;
28+ None
3229}
3330
3431#[ test]
3532fn 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" ) ;
4436}
You can’t perform that action at this time.
0 commit comments