13
13
use container:: Container ;
14
14
use c_str:: CString ;
15
15
use clone:: Clone ;
16
- use iterator :: Iterator ;
16
+ use iter :: Iterator ;
17
17
use option:: { Option , None , Some } ;
18
18
use str;
19
19
use str:: StrSlice ;
@@ -102,7 +102,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
102
102
/// If the path is not representable in utf-8, this returns None.
103
103
#[ inline]
104
104
fn as_str < ' a > ( & ' a self ) -> Option < & ' a str > {
105
- str:: from_bytes_slice_opt ( self . as_vec ( ) )
105
+ str:: from_utf8_slice_opt ( self . as_vec ( ) )
106
106
}
107
107
108
108
/// Returns the path as a byte vector
@@ -115,7 +115,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
115
115
/// See `dirname` for details.
116
116
#[ inline]
117
117
fn dirname_str < ' a > ( & ' a self ) -> Option < & ' a str > {
118
- str:: from_bytes_slice_opt ( self . dirname ( ) )
118
+ str:: from_utf8_slice_opt ( self . dirname ( ) )
119
119
}
120
120
/// Returns the file component of `self`, as a byte vector.
121
121
/// If `self` represents the root of the file hierarchy, returns the empty vector.
@@ -125,7 +125,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
125
125
/// See `filename` for details.
126
126
#[ inline]
127
127
fn filename_str < ' a > ( & ' a self ) -> Option < & ' a str > {
128
- str:: from_bytes_slice_opt ( self . filename ( ) )
128
+ str:: from_utf8_slice_opt ( self . filename ( ) )
129
129
}
130
130
/// Returns the stem of the filename of `self`, as a byte vector.
131
131
/// The stem is the portion of the filename just before the last '.'.
@@ -143,7 +143,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
143
143
/// See `filestem` for details.
144
144
#[ inline]
145
145
fn filestem_str < ' a > ( & ' a self ) -> Option < & ' a str > {
146
- str:: from_bytes_slice_opt ( self . filestem ( ) )
146
+ str:: from_utf8_slice_opt ( self . filestem ( ) )
147
147
}
148
148
/// Returns the extension of the filename of `self`, as an optional byte vector.
149
149
/// The extension is the portion of the filename just after the last '.'.
@@ -162,7 +162,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
162
162
/// See `extension` for details.
163
163
#[ inline]
164
164
fn extension_str < ' a > ( & ' a self ) -> Option < & ' a str > {
165
- self . extension ( ) . chain ( |v| str:: from_bytes_slice_opt ( v) )
165
+ self . extension ( ) . and_then ( |v| str:: from_utf8_slice_opt ( v) )
166
166
}
167
167
168
168
/// Replaces the directory portion of the path with the given byte vector.
@@ -447,7 +447,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
447
447
/// See `pop_opt` for details.
448
448
#[ inline]
449
449
fn pop_opt_str ( & mut self ) -> Option < ~str > {
450
- self . pop_opt ( ) . chain ( |v| str:: from_bytes_owned_opt ( v) )
450
+ self . pop_opt ( ) . and_then ( |v| str:: from_utf8_owned_opt ( v) )
451
451
}
452
452
453
453
/// Returns a new Path constructed by joining `self` with the given path (as a byte vector).
0 commit comments