@@ -158,15 +158,15 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
158
158
/// See individual Path impls for additional restrictions.
159
159
#[ inline]
160
160
fn new < T : BytesContainer > ( path : T ) -> Self {
161
- assert ! ( !contains_nul( path. container_as_bytes ( ) ) ) ;
161
+ assert ! ( !contains_nul( & path) ) ;
162
162
unsafe { GenericPathUnsafe :: new_unchecked ( path) }
163
163
}
164
164
165
165
/// Creates a new Path from a byte vector or string, if possible.
166
166
/// The resulting Path will always be normalized.
167
167
#[ inline]
168
168
fn new_opt < T : BytesContainer > ( path : T ) -> Option < Self > {
169
- if contains_nul ( path. container_as_bytes ( ) ) {
169
+ if contains_nul ( & path) {
170
170
None
171
171
} else {
172
172
Some ( unsafe { GenericPathUnsafe :: new_unchecked ( path) } )
@@ -274,7 +274,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
274
274
/// Fails the task if the filename contains a NUL.
275
275
#[ inline]
276
276
fn set_filename < T : BytesContainer > ( & mut self , filename : T ) {
277
- assert ! ( !contains_nul( filename. container_as_bytes ( ) ) ) ;
277
+ assert ! ( !contains_nul( & filename) ) ;
278
278
unsafe { self . set_filename_unchecked ( filename) }
279
279
}
280
280
/// Replaces the extension with the given byte vector or string.
@@ -286,7 +286,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
286
286
///
287
287
/// Fails the task if the extension contains a NUL.
288
288
fn set_extension < T : BytesContainer > ( & mut self , extension : T ) {
289
- assert ! ( !contains_nul( extension. container_as_bytes ( ) ) ) ;
289
+ assert ! ( !contains_nul( & extension) ) ;
290
290
// borrowck causes problems here too
291
291
let val = {
292
292
match self . filename ( ) {
@@ -376,7 +376,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
376
376
/// Fails the task if the path contains a NUL.
377
377
#[ inline]
378
378
fn push < T : BytesContainer > ( & mut self , path : T ) {
379
- assert ! ( !contains_nul( path. container_as_bytes ( ) ) ) ;
379
+ assert ! ( !contains_nul( & path) ) ;
380
380
unsafe { self . push_unchecked ( path) }
381
381
}
382
382
/// Pushes multiple paths (as byte vectors or strings) onto `self`.
@@ -589,8 +589,8 @@ impl<'a> BytesContainer for str::MaybeOwned<'a> {
589
589
}
590
590
591
591
#[ 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 )
594
594
}
595
595
596
596
#[ cfg( test) ]
0 commit comments