@@ -238,65 +238,41 @@ impl_into_root_cert_store_for_types!(
238
238
/// This trait is used to provide a unified way to convert different types
239
239
/// into an optional `Cow` containing a slice of `CertCompressionAlgorithm`.
240
240
pub trait IntoCertCompressionAlgorithm {
241
- /// Converts the implementing type into an optional `Cow` containing a slice of `CertCompressionAlgorithm`.
242
241
fn into ( self ) -> Option < Cow < ' static , [ CertCompressionAlgorithm ] > > ;
243
242
}
244
243
245
- macro_rules! impl_into_cert_compression_algorithm_for_types {
246
- ( $( $t: ty => $body: expr) ,* ) => {
247
- $(
248
- impl IntoCertCompressionAlgorithm for $t {
249
- fn into( self ) -> Option <Cow <' static , [ CertCompressionAlgorithm ] >> {
250
- $body( self )
251
- }
252
- }
253
- ) *
254
- } ;
255
- }
256
-
257
- macro_rules! impl_into_cert_compression_algorithm_for_arrays {
258
- ( $( $t: ty => $body: expr) ,* ) => {
259
- $(
260
- impl <const N : usize > IntoCertCompressionAlgorithm for $t {
261
- fn into( self ) -> Option <Cow <' static , [ CertCompressionAlgorithm ] >> {
262
- $body( self )
263
- }
244
+ macro_rules! impl_into_cert_compression_algorithm {
245
+ ( $( $t: ty => $body: expr) ,* $( , ) ?) => {
246
+ $( impl IntoCertCompressionAlgorithm for $t {
247
+ fn into( self ) -> Option <Cow <' static , [ CertCompressionAlgorithm ] >> {
248
+ $body( self )
264
249
}
265
- ) *
250
+ } ) *
266
251
} ;
267
252
}
268
253
269
- impl_into_cert_compression_algorithm_for_types ! (
254
+ impl_into_cert_compression_algorithm ! (
270
255
& ' static [ CertCompressionAlgorithm ] => |s| Some ( Cow :: Borrowed ( s) ) ,
271
- Option <& ' static [ CertCompressionAlgorithm ] > => |s: Option <& ' static [ CertCompressionAlgorithm ] >| s. map( Cow :: Borrowed )
272
- ) ;
273
-
274
- impl_into_cert_compression_algorithm_for_types ! (
275
256
Cow <' static , [ CertCompressionAlgorithm ] > => Some ,
276
- Option <Cow <' static , [ CertCompressionAlgorithm ] >> => |s| s
277
- ) ;
278
-
279
- impl_into_cert_compression_algorithm_for_types ! (
280
257
& ' static CertCompressionAlgorithm => |s: & ' static CertCompressionAlgorithm | Some ( Cow :: Owned ( vec![ * s] ) ) ,
281
- Option <& ' static CertCompressionAlgorithm > => |s: Option <& ' static CertCompressionAlgorithm >| s. map( |alg| Cow :: Owned ( vec![ * alg] ) )
282
- ) ;
283
-
284
- impl_into_cert_compression_algorithm_for_types ! (
285
258
CertCompressionAlgorithm => |s| Some ( Cow :: Owned ( vec![ s] ) ) ,
286
- Option <CertCompressionAlgorithm > => |s: Option <CertCompressionAlgorithm >| s. map( |alg| Cow :: Owned ( vec![ alg] ) )
287
- ) ;
288
-
289
- impl_into_cert_compression_algorithm_for_types ! (
290
259
Vec <CertCompressionAlgorithm > => |s| Some ( Cow :: Owned ( s) ) ,
291
- Option <Vec <CertCompressionAlgorithm >> => |s: Option <Vec <CertCompressionAlgorithm >>| s. map( Cow :: Owned )
292
260
) ;
293
261
294
- impl_into_cert_compression_algorithm_for_arrays ! (
295
- & ' static [ CertCompressionAlgorithm ; N ] => |s: & ' static [ CertCompressionAlgorithm ; N ] | Some ( Cow :: Borrowed ( & s[ ..] ) ) ,
296
- Option <& ' static [ CertCompressionAlgorithm ; N ] > => |s: Option <& ' static [ CertCompressionAlgorithm ; N ] >| s. map( |s| Cow :: Borrowed ( & s[ ..] ) )
297
- ) ;
262
+ impl < const N : usize > IntoCertCompressionAlgorithm for & ' static [ CertCompressionAlgorithm ; N ] {
263
+ fn into ( self ) -> Option < Cow < ' static , [ CertCompressionAlgorithm ] > > {
264
+ Some ( Cow :: Borrowed ( self ) )
265
+ }
266
+ }
298
267
299
- impl_into_cert_compression_algorithm_for_arrays ! (
300
- [ CertCompressionAlgorithm ; N ] => |s: [ CertCompressionAlgorithm ; N ] | Some ( Cow :: Owned ( s. to_vec( ) ) ) ,
301
- Option <[ CertCompressionAlgorithm ; N ] > => |s: Option <[ CertCompressionAlgorithm ; N ] >| s. map( |arr| Cow :: Owned ( arr. to_vec( ) ) )
302
- ) ;
268
+ impl < const N : usize > IntoCertCompressionAlgorithm for [ CertCompressionAlgorithm ; N ] {
269
+ fn into ( self ) -> Option < Cow < ' static , [ CertCompressionAlgorithm ] > > {
270
+ Some ( Cow :: Owned ( self . to_vec ( ) ) )
271
+ }
272
+ }
273
+
274
+ impl < T : IntoCertCompressionAlgorithm > IntoCertCompressionAlgorithm for Option < T > {
275
+ fn into ( self ) -> Option < Cow < ' static , [ CertCompressionAlgorithm ] > > {
276
+ self . and_then ( |v| v. into ( ) )
277
+ }
278
+ }
0 commit comments