@@ -17,14 +17,22 @@ pub struct WindowsPath {
17
17
components : ~[ ~str ] ,
18
18
}
19
19
20
+ pub pure fn WindowsPath ( s : & str ) -> WindowsPath {
21
+ from_str ( s)
22
+ }
23
+
20
24
pub struct PosixPath {
21
25
is_absolute : bool ,
22
26
components : ~[ ~str ] ,
23
27
}
24
28
29
+ pub pure fn PosixPath ( s : & str ) -> PosixPath {
30
+ from_str ( s)
31
+ }
32
+
25
33
pub trait GenericPath {
26
34
27
- static pure fn from_str( ( & str ) ) -> self ;
35
+ static pure fn from_str( & str ) -> self ;
28
36
29
37
pure fn dirname( ) -> ~str ;
30
38
pure fn filename( ) -> Option <~str >;
@@ -49,15 +57,15 @@ pub type Path = WindowsPath;
49
57
50
58
#[ cfg( windows) ]
51
59
pub pure fn Path ( s: & str ) -> Path {
52
- from_str :: < WindowsPath > ( s )
60
+ WindowsPath ( s )
53
61
}
54
62
55
63
#[ cfg( unix) ]
56
64
pub type Path = PosixPath ;
57
65
58
66
#[ cfg( unix) ]
59
67
pub pure fn Path ( s : & str ) -> Path {
60
- from_str :: < PosixPath > ( s)
68
+ PosixPath ( s)
61
69
}
62
70
63
71
impl PosixPath : ToStr {
@@ -166,7 +174,7 @@ impl PosixPath : GenericPath {
166
174
}
167
175
168
176
pure fn with_dirname ( d : & str ) -> PosixPath {
169
- let dpath = from_str :: < PosixPath > ( d) ;
177
+ let dpath = PosixPath ( d) ;
170
178
match self . filename ( ) {
171
179
Some ( ref f) => dpath. push ( * f) ,
172
180
None => move dpath
@@ -365,7 +373,7 @@ impl WindowsPath : GenericPath {
365
373
}
366
374
367
375
pure fn with_dirname ( d : & str ) -> WindowsPath {
368
- let dpath = from_str :: < WindowsPath > ( d) ;
376
+ let dpath = WindowsPath ( d) ;
369
377
match self . filename ( ) {
370
378
Some ( ref f) => dpath. push ( * f) ,
371
379
None => move dpath
@@ -493,12 +501,12 @@ pub pure fn normalize(components: &[~str]) -> ~[~str] {
493
501
#[test]
494
502
fn test_double_slash_collapsing()
495
503
{
496
- let path = from_str::< PosixPath> (" tmp/") ;
504
+ let path = PosixPath(" tmp/") ;
497
505
let path = path. push ( "/hmm" ) ;
498
506
let path = path. normalize ( ) ;
499
507
assert ~"tmp/hmm" == path. to_str ( ) ;
500
508
501
- let path = from_str :: < WindowsPath > ( "tmp/" ) ;
509
+ let path = WindowsPath ( "tmp/" ) ;
502
510
let path = path. push ( "/hmm" ) ;
503
511
let path = path. normalize ( ) ;
504
512
assert ~"tmp\\ hmm" == path. to_str ( ) ;
@@ -507,7 +515,7 @@ fn test_double_slash_collapsing()
507
515
mod posix {
508
516
509
517
#[ cfg( test) ]
510
- fn mk ( s : & str ) -> PosixPath { from_str :: < PosixPath > ( s) }
518
+ fn mk ( s : & str ) -> PosixPath { PosixPath ( s) }
511
519
512
520
#[ cfg( test) ]
513
521
fn t ( wp : & PosixPath , s : & str ) {
@@ -661,7 +669,7 @@ mod windows {
661
669
662
670
#[ test]
663
671
fn test_windows_paths ( ) {
664
- fn mk ( s : & str ) -> WindowsPath { from_str :: < WindowsPath > ( s) }
672
+ fn mk ( s : & str ) -> WindowsPath { WindowsPath ( s) }
665
673
fn t ( wp : & WindowsPath , s : & str ) {
666
674
let ss = wp. to_str ( ) ;
667
675
let sss = str:: from_slice ( s) ;
@@ -705,7 +713,7 @@ mod windows {
705
713
}
706
714
707
715
#[ cfg( test) ]
708
- fn mk ( s : & str ) -> PosixPath { from_str :: < PosixPath > ( s) }
716
+ fn mk ( s : & str ) -> PosixPath { PosixPath ( s) }
709
717
710
718
#[ test]
711
719
fn test_filetype_foo_bar ( ) {
0 commit comments