@@ -72,26 +72,27 @@ impl<'a> Cmdline<'a> {
7272 ///
7373 /// Returns the first parameter matching the given key, or `None` if not found.
7474 /// Key comparison treats dashes and underscores as equivalent.
75- pub fn find ( & ' a self , key : impl AsRef < str > ) -> Option < Parameter < ' a > > {
75+ pub fn find < T : AsRef < str > + ? Sized > ( & ' a self , key : & T ) -> Option < Parameter < ' a > > {
7676 let key = ParameterKey :: from ( key. as_ref ( ) ) ;
7777 self . iter ( ) . find ( |p| p. key ( ) == key)
7878 }
7979
8080 /// Find all kernel arguments starting with the given UTF-8 prefix.
8181 ///
8282 /// This is a variant of [`Self::find`].
83- pub fn find_all_starting_with (
83+ pub fn find_all_starting_with < T : AsRef < str > + ? Sized > (
8484 & ' a self ,
85- prefix : & ' a str ,
85+ prefix : & ' a T ,
8686 ) -> impl Iterator < Item = Parameter < ' a > > + ' a {
87- self . iter ( ) . filter ( move |p| p. key ( ) . starts_with ( prefix) )
87+ self . iter ( )
88+ . filter ( move |p| p. key ( ) . starts_with ( prefix. as_ref ( ) ) )
8889 }
8990
9091 /// Locate the value of the kernel argument with the given key name.
9192 ///
9293 /// Returns the first value matching the given key, or `None` if not found.
9394 /// Key comparison treats dashes and underscores as equivalent.
94- pub fn value_of ( & ' a self , key : impl AsRef < str > ) -> Option < & ' a str > {
95+ pub fn value_of < T : AsRef < str > + ? Sized > ( & ' a self , key : & T ) -> Option < & ' a str > {
9596 self . 0 . value_of ( key. as_ref ( ) . as_bytes ( ) ) . map ( |v| {
9697 // SAFETY: We know this is valid UTF-8 since we only
9798 // construct the underlying `bytes` from valid UTF-8
@@ -102,7 +103,7 @@ impl<'a> Cmdline<'a> {
102103 /// Find the value of the kernel argument with the provided name, which must be present.
103104 ///
104105 /// Otherwise the same as [`Self::value_of`].
105- pub fn require_value_of ( & ' a self , key : impl AsRef < str > ) -> Result < & ' a str > {
106+ pub fn require_value_of < T : AsRef < str > + ? Sized > ( & ' a self , key : & T ) -> Result < & ' a str > {
106107 let key = key. as_ref ( ) ;
107108 self . value_of ( key)
108109 . ok_or_else ( || anyhow:: anyhow!( "Failed to find kernel argument '{key}'" ) )
@@ -159,9 +160,9 @@ impl<'a> ParameterKey<'a> {
159160 }
160161}
161162
162- impl < ' a > From < & ' a str > for ParameterKey < ' a > {
163- fn from ( input : & ' a str ) -> Self {
164- Self ( bytes:: ParameterKey ( input. as_bytes ( ) ) )
163+ impl < ' a , T : AsRef < str > + ? Sized > From < & ' a T > for ParameterKey < ' a > {
164+ fn from ( input : & ' a T ) -> Self {
165+ Self ( bytes:: ParameterKey ( input. as_ref ( ) . as_bytes ( ) ) )
165166 }
166167}
167168
@@ -197,8 +198,8 @@ impl<'a> Parameter<'a> {
197198 ///
198199 /// Any remaining characters not consumed from the input are
199200 /// returned as the second tuple item.
200- pub fn parse ( input : & ' a str ) -> ( Option < Self > , & ' a str ) {
201- let ( bytes, rest) = bytes:: Parameter :: parse ( input. as_bytes ( ) ) ;
201+ pub fn parse < T : AsRef < str > + ? Sized > ( input : & ' a T ) -> ( Option < Self > , & ' a str ) {
202+ let ( bytes, rest) = bytes:: Parameter :: parse ( input. as_ref ( ) . as_bytes ( ) ) ;
202203
203204 // SAFETY: we know this is valid UTF-8 since input is &str,
204205 // and `rest` is a subslice of that &str which was split on
0 commit comments