@@ -389,13 +389,11 @@ impl GenericPath for PosixPath {
389
389
}
390
390
391
391
fn dirname ( & self ) -> ~str {
392
- unsafe {
393
- let s = self . dir_path ( ) . to_str ( ) ;
394
- if s. len ( ) == 0 {
395
- ~". "
396
- } else {
397
- s
398
- }
392
+ let s = self . dir_path ( ) . to_str ( ) ;
393
+ if s. len ( ) == 0 {
394
+ ~". "
395
+ } else {
396
+ s
399
397
}
400
398
}
401
399
@@ -439,10 +437,8 @@ impl GenericPath for PosixPath {
439
437
}
440
438
441
439
fn with_filename ( & self , f : & str ) -> PosixPath {
442
- unsafe {
443
- assert ! ( ! str :: any( f, |c| windows:: is_sep( c as u8 ) ) ) ;
444
- self . dir_path ( ) . push ( f)
445
- }
440
+ assert ! ( ! str :: any( f, |c| windows:: is_sep( c as u8 ) ) ) ;
441
+ self . dir_path ( ) . push ( f)
446
442
}
447
443
448
444
fn with_filestem ( & self , s : & str ) -> PosixPath {
@@ -509,7 +505,7 @@ impl GenericPath for PosixPath {
509
505
for str:: each_split_nonempty( * e, |c| windows:: is_sep( c as u8) ) |s| {
510
506
ss. push ( s. to_owned ( ) )
511
507
}
512
- unsafe { v. push_all_move ( ss) ; }
508
+ v. push_all_move ( ss) ;
513
509
}
514
510
PosixPath { is_absolute : self . is_absolute ,
515
511
components : v }
@@ -521,14 +517,14 @@ impl GenericPath for PosixPath {
521
517
for str:: each_split_nonempty( s, |c| windows:: is_sep( c as u8) ) |s| {
522
518
ss. push ( s. to_owned ( ) )
523
519
}
524
- unsafe { v. push_all_move ( ss) ; }
520
+ v. push_all_move ( ss) ;
525
521
PosixPath { components : v, ..copy * self }
526
522
}
527
523
528
524
fn pop ( & self ) -> PosixPath {
529
525
let mut cs = copy self . components ;
530
526
if cs. len ( ) != 0 {
531
- unsafe { cs. pop ( ) ; }
527
+ cs. pop ( ) ;
532
528
}
533
529
return PosixPath {
534
530
is_absolute : self . is_absolute ,
@@ -607,13 +603,11 @@ impl GenericPath for WindowsPath {
607
603
}
608
604
609
605
fn dirname ( & self ) -> ~str {
610
- unsafe {
611
- let s = self . dir_path ( ) . to_str ( ) ;
612
- if s. len ( ) == 0 {
613
- ~". "
614
- } else {
615
- s
616
- }
606
+ let s = self . dir_path ( ) . to_str ( ) ;
607
+ if s. len ( ) == 0 {
608
+ ~". "
609
+ } else {
610
+ s
617
611
}
618
612
}
619
613
@@ -770,7 +764,7 @@ impl GenericPath for WindowsPath {
770
764
for str:: each_split_nonempty( * e, |c| windows:: is_sep( c as u8) ) |s| {
771
765
ss. push ( s. to_owned ( ) )
772
766
}
773
- unsafe { v. push_all_move ( ss) ; }
767
+ v. push_all_move ( ss) ;
774
768
}
775
769
// tedious, but as-is, we can't use ..self
776
770
return WindowsPath {
@@ -787,14 +781,14 @@ impl GenericPath for WindowsPath {
787
781
for str:: each_split_nonempty( s, |c| windows:: is_sep( c as u8) ) |s| {
788
782
ss. push ( s. to_owned ( ) )
789
783
}
790
- unsafe { v. push_all_move ( ss) ; }
784
+ v. push_all_move ( ss) ;
791
785
return WindowsPath { components : v, ..copy * self }
792
786
}
793
787
794
788
fn pop ( & self ) -> WindowsPath {
795
789
let mut cs = copy self . components ;
796
790
if cs. len ( ) != 0 {
797
- unsafe { cs. pop ( ) ; }
791
+ cs. pop ( ) ;
798
792
}
799
793
return WindowsPath {
800
794
host : copy self . host ,
@@ -820,18 +814,14 @@ impl GenericPath for WindowsPath {
820
814
821
815
pub fn normalize( components : & [ ~str ] ) -> ~[ ~str ] {
822
816
let mut cs = ~[ ] ;
823
- unsafe {
824
- for components. each |c| {
825
- unsafe {
826
- if * c == ~". " && components. len ( ) > 1 { loop ; }
827
- if * c == ~"" { loop ; }
828
- if * c == ~".." && cs.len() != 0 {
829
- cs.pop();
830
- loop;
831
- }
832
- cs.push(copy *c);
833
- }
817
+ for components. each |c| {
818
+ if * c == ~". " && components. len ( ) > 1 { loop ; }
819
+ if * c == ~"" { loop ; }
820
+ if * c == ~".." && cs.len() != 0 {
821
+ cs.pop();
822
+ loop;
834
823
}
824
+ cs.push(copy *c);
835
825
}
836
826
cs
837
827
}
0 commit comments