@@ -129,11 +129,7 @@ impl BytesContainer for Path {
129129 self . into_vec ( )
130130 }
131131 #[ inline]
132- fn container_as_str < ' a > ( & ' a self ) -> & ' a str {
133- self . as_str ( ) . unwrap ( )
134- }
135- #[ inline]
136- fn container_as_str_opt < ' a > ( & ' a self ) -> Option < & ' a str > {
132+ fn container_as_str < ' a > ( & ' a self ) -> Option < & ' a str > {
137133 self . as_str ( )
138134 }
139135 #[ inline]
@@ -146,11 +142,7 @@ impl<'a> BytesContainer for &'a Path {
146142 self . as_vec ( )
147143 }
148144 #[ inline]
149- fn container_as_str < ' a > ( & ' a self ) -> & ' a str {
150- self . as_str ( ) . unwrap ( )
151- }
152- #[ inline]
153- fn container_as_str_opt < ' a > ( & ' a self ) -> Option < & ' a str > {
145+ fn container_as_str < ' a > ( & ' a self ) -> Option < & ' a str > {
154146 self . as_str ( )
155147 }
156148 #[ inline]
@@ -165,7 +157,7 @@ impl GenericPathUnsafe for Path {
165157 /// Raises the `str::not_utf8` condition if not valid UTF-8.
166158 #[ inline]
167159 unsafe fn new_unchecked < T : BytesContainer > ( path : T ) -> Path {
168- let ( prefix, path) = Path :: normalize_ ( path. container_as_str ( ) ) ;
160+ let ( prefix, path) = Path :: normalize_ ( path. container_as_str ( ) . unwrap ( ) ) ;
169161 assert ! ( !path. is_empty( ) ) ;
170162 let mut ret = Path { repr : path, prefix : prefix, sepidx : None } ;
171163 ret. update_sepidx ( ) ;
@@ -178,7 +170,7 @@ impl GenericPathUnsafe for Path {
178170 ///
179171 /// Raises the `str::not_utf8` condition if not valid UTF-8.
180172 unsafe fn set_filename_unchecked < T : BytesContainer > ( & mut self , filename : T ) {
181- let filename = filename. container_as_str ( ) ;
173+ let filename = filename. container_as_str ( ) . unwrap ( ) ;
182174 match self . sepidx_or_prefix_len ( ) {
183175 None if ".." == self . repr => {
184176 let mut s = str:: with_capacity ( 3 + filename. len ( ) ) ;
@@ -224,7 +216,7 @@ impl GenericPathUnsafe for Path {
224216 /// the new path is relative to. Otherwise, the new path will be treated
225217 /// as if it were absolute and will replace the receiver outright.
226218 unsafe fn push_unchecked < T : BytesContainer > ( & mut self , path : T ) {
227- let path = path. container_as_str ( ) ;
219+ let path = path. container_as_str ( ) . unwrap ( ) ;
228220 fn is_vol_abs ( path : & str , prefix : Option < PathPrefix > ) -> bool {
229221 // assume prefix is Some(DiskPrefix)
230222 let rest = path. slice_from ( prefix_len ( prefix) ) ;
@@ -311,7 +303,7 @@ impl GenericPathUnsafe for Path {
311303impl GenericPath for Path {
312304 #[ inline]
313305 fn new_opt < T : BytesContainer > ( path : T ) -> Option < Path > {
314- let s = path. container_as_str_opt ( ) ;
306+ let s = path. container_as_str ( ) ;
315307 match s {
316308 None => None ,
317309 Some ( s) => {
0 commit comments