File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
crates/kernel_cmdline/src Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ use anyhow::Result;
1414/// Wraps the raw command line bytes and provides methods for parsing and iterating
1515/// over individual parameters. Uses copy-on-write semantics to avoid unnecessary
1616/// allocations when working with borrowed data.
17- #[ derive( Debug ) ]
17+ #[ derive( Debug , Default ) ]
1818pub struct Cmdline < ' a > ( Cow < ' a , [ u8 ] > ) ;
1919
2020impl < ' a , T : AsRef < [ u8 ] > + ?Sized > From < & ' a T > for Cmdline < ' a > {
@@ -539,6 +539,12 @@ mod tests {
539539 assert ! ( kargs. find( "nothing" ) . is_none( ) ) ;
540540 }
541541
542+ #[ test]
543+ fn test_cmdline_default ( ) {
544+ let kargs: Cmdline = Default :: default ( ) ;
545+ assert_eq ! ( kargs. iter( ) . next( ) , None ) ;
546+ }
547+
542548 #[ test]
543549 fn test_kargs_iter_utf8 ( ) {
544550 let kargs = Cmdline :: from ( b"foo=bar,bar2 \xff baz=fuz bad=oh\xff no wiz" ) ;
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ use anyhow::Result;
1414/// Wraps the raw command line bytes and provides methods for parsing and iterating
1515/// over individual parameters. Uses copy-on-write semantics to avoid unnecessary
1616/// allocations when working with borrowed data.
17- #[ derive( Debug ) ]
17+ #[ derive( Debug , Default ) ]
1818pub struct Cmdline < ' a > ( bytes:: Cmdline < ' a > ) ;
1919
2020impl < ' a , T : AsRef < str > + ?Sized > From < & ' a T > for Cmdline < ' a > {
@@ -494,6 +494,12 @@ mod tests {
494494 assert ! ( kargs. find( "nothing" ) . is_none( ) ) ;
495495 }
496496
497+ #[ test]
498+ fn test_cmdline_default ( ) {
499+ let kargs: Cmdline = Default :: default ( ) ;
500+ assert_eq ! ( kargs. iter( ) . next( ) , None ) ;
501+ }
502+
497503 #[ test]
498504 fn test_kargs_simple_from_string ( ) {
499505 let kargs = Cmdline :: from ( "foo=bar,bar2 baz=fuz wiz" . to_string ( ) ) ;
You can’t perform that action at this time.
0 commit comments