File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ use core::{
13
13
/// A fixed capacity [`CString`](https://doc.rust-lang.org/std/ffi/struct.CString.html).
14
14
///
15
15
/// It stores up to `N - 1` non-nul characters with a trailing nul terminator.
16
- #[ derive( Clone , Default , Hash ) ]
16
+ #[ derive( Clone , Hash ) ]
17
17
pub struct CString < const N : usize > {
18
18
inner : Vec < u8 , N > ,
19
19
}
@@ -273,6 +273,13 @@ impl<const N: usize> CString<N> {
273
273
}
274
274
}
275
275
276
+ impl < const N : usize > Default for CString < N > {
277
+ #[ inline]
278
+ fn default ( ) -> Self {
279
+ Self :: new ( )
280
+ }
281
+ }
282
+
276
283
impl < const N : usize > Borrow < CStr > for CString < N > {
277
284
#[ inline]
278
285
fn borrow ( & self ) -> & CStr {
@@ -445,6 +452,10 @@ mod tests {
445
452
Some ( INITIAL_BYTES . len( ) + 5 )
446
453
) ;
447
454
}
455
+ #[ test]
456
+ fn default ( ) {
457
+ assert_eq ! ( CString :: <1 >:: default ( ) . as_c_str( ) , <& CStr >:: default ( ) ) ;
458
+ }
448
459
449
460
#[ test]
450
461
fn deref ( ) {
You can’t perform that action at this time.
0 commit comments