@@ -158,15 +158,15 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
158158 /// See individual Path impls for additional restrictions.
159159 #[ inline]
160160 fn new < T : BytesContainer > ( path : T ) -> Self {
161- assert ! ( !contains_nul( path. container_as_bytes ( ) ) ) ;
161+ assert ! ( !contains_nul( & path) ) ;
162162 unsafe { GenericPathUnsafe :: new_unchecked ( path) }
163163 }
164164
165165 /// Creates a new Path from a byte vector or string, if possible.
166166 /// The resulting Path will always be normalized.
167167 #[ inline]
168168 fn new_opt < T : BytesContainer > ( path : T ) -> Option < Self > {
169- if contains_nul ( path. container_as_bytes ( ) ) {
169+ if contains_nul ( & path) {
170170 None
171171 } else {
172172 Some ( unsafe { GenericPathUnsafe :: new_unchecked ( path) } )
@@ -274,7 +274,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
274274 /// Fails the task if the filename contains a NUL.
275275 #[ inline]
276276 fn set_filename < T : BytesContainer > ( & mut self , filename : T ) {
277- assert ! ( !contains_nul( filename. container_as_bytes ( ) ) ) ;
277+ assert ! ( !contains_nul( & filename) ) ;
278278 unsafe { self . set_filename_unchecked ( filename) }
279279 }
280280 /// Replaces the extension with the given byte vector or string.
@@ -286,7 +286,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
286286 ///
287287 /// Fails the task if the extension contains a NUL.
288288 fn set_extension < T : BytesContainer > ( & mut self , extension : T ) {
289- assert ! ( !contains_nul( extension. container_as_bytes ( ) ) ) ;
289+ assert ! ( !contains_nul( & extension) ) ;
290290 // borrowck causes problems here too
291291 let val = {
292292 match self . filename ( ) {
@@ -376,7 +376,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
376376 /// Fails the task if the path contains a NUL.
377377 #[ inline]
378378 fn push < T : BytesContainer > ( & mut self , path : T ) {
379- assert ! ( !contains_nul( path. container_as_bytes ( ) ) ) ;
379+ assert ! ( !contains_nul( & path) ) ;
380380 unsafe { self . push_unchecked ( path) }
381381 }
382382 /// Pushes multiple paths (as byte vectors or strings) onto `self`.
@@ -589,8 +589,8 @@ impl<'a> BytesContainer for str::MaybeOwned<'a> {
589589}
590590
591591#[ inline( always) ]
592- fn contains_nul ( v : & [ u8 ] ) -> bool {
593- v. iter ( ) . any ( |& x| x == 0 )
592+ fn contains_nul < T : BytesContainer > ( v : & T ) -> bool {
593+ v. container_as_bytes ( ) . iter ( ) . any ( |& x| x == 0 )
594594}
595595
596596#[ cfg( test) ]
0 commit comments