@@ -318,27 +318,11 @@ impl StateMachine for Encrypter {
318
318
}
319
319
}
320
320
321
- // This is a workaround to allow calling a Box<FnOnce> in Rust versions less
322
- // than 1.35. When the MSRV is 1.35 or greater, this can be removed and
323
- // replaced directly with `Box<dyn FnOnce(...)>`.
324
- //
325
- // Refer to https://github.com/rust-lang/rust/issues/28796 for more info.
326
- pub ( crate ) trait KeyLookupFn {
327
- fn call_box ( self : Box < Self > , public_key : & PublicKey ) -> Option < SecretKey > ;
328
- }
329
-
330
- impl < T > KeyLookupFn for T
331
- where
332
- T : FnOnce ( & PublicKey ) -> Option < SecretKey > ,
333
- {
334
- fn call_box ( self : Box < Self > , public_key : & PublicKey ) -> Option < SecretKey > {
335
- ( * self ) ( public_key)
336
- }
337
- }
321
+ type KeyLookupFn = Box < dyn FnOnce ( & PublicKey ) -> Option < SecretKey > > ;
338
322
339
323
pub ( crate ) enum KeyResolution {
340
324
Available ( PublicKey , SecretKey ) ,
341
- Deferred ( Box < dyn KeyLookupFn > ) ,
325
+ Deferred ( KeyLookupFn ) ,
342
326
}
343
327
344
328
impl fmt:: Debug for KeyResolution {
@@ -354,7 +338,7 @@ impl fmt::Debug for KeyResolution {
354
338
pub ( crate ) enum DecrypterState {
355
339
ReadPreheader ( KeyResolution ) ,
356
340
ReadPublicKey ( KeyResolution ) ,
357
- SecretKeyLookup ( PublicKey , Box < dyn KeyLookupFn > ) ,
341
+ SecretKeyLookup ( PublicKey , KeyLookupFn ) ,
358
342
ReadHeader ( PublicKey , PublicKey , SecretKey ) ,
359
343
OpenStream ( Key , Header ) ,
360
344
ReadLength ( Stream < Pull > ) ,
@@ -480,7 +464,7 @@ impl Decrypter {
480
464
}
481
465
} ,
482
466
SecretKeyLookup ( file_public_key, lookup_fn) => {
483
- if let Some ( secret_key) = lookup_fn. call_box ( & file_public_key) {
467
+ if let Some ( secret_key) = lookup_fn ( & file_public_key) {
484
468
state:: next ( ReadHeader (
485
469
file_public_key. clone ( ) ,
486
470
file_public_key,
0 commit comments