@@ -704,6 +704,16 @@ impl<'a, Args, Output> AsRef<Self> for dyn FnOnce<Args, Output = Output> + Send
704704 self
705705 }
706706}
707+ impl < ' a , A , Output > AsRef < Self > for dyn for < ' r > FnOnce < ( & ' r A , ) , Output = Output > + ' a {
708+ fn as_ref ( & self ) -> & Self {
709+ self
710+ }
711+ }
712+ impl < ' a , A , Output > AsRef < Self > for dyn for < ' r > FnOnce < ( & ' r A , ) , Output = Output > + Send + ' a {
713+ fn as_ref ( & self ) -> & Self {
714+ self
715+ }
716+ }
707717
708718impl < Args : ' static , Output : ' static > serde:: ser:: Serialize for dyn FnOnce < Args , Output = Output > {
709719 fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
@@ -744,6 +754,50 @@ impl<'de, Args: 'static, Output: 'static> serde::de::Deserialize<'de>
744754 . map ( |x| x. 0 )
745755 }
746756}
757+ impl < A : ' static , Output : ' static > serde:: ser:: Serialize
758+ for dyn for < ' r > FnOnce < ( & ' r A , ) , Output = Output >
759+ {
760+ fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
761+ where
762+ S : serde:: Serializer ,
763+ {
764+ serialize ( self , serializer)
765+ }
766+ }
767+ impl < ' de , A : ' static , Output : ' static > serde:: de:: Deserialize < ' de >
768+ for boxed:: Box < dyn for < ' r > FnOnce < ( & ' r A , ) , Output = Output > + ' static >
769+ {
770+ fn deserialize < D > ( deserializer : D ) -> Result < Self , D :: Error >
771+ where
772+ D : serde:: Deserializer < ' de > ,
773+ {
774+ <Box < dyn for < ' r > FnOnce < ( & ' r A , ) , Output = Output > + ' static > >:: deserialize ( deserializer)
775+ . map ( |x| x. 0 )
776+ }
777+ }
778+ impl < A : ' static , Output : ' static > serde:: ser:: Serialize
779+ for dyn for < ' r > FnOnce < ( & ' r A , ) , Output = Output > + Send
780+ {
781+ fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
782+ where
783+ S : serde:: Serializer ,
784+ {
785+ serialize ( self , serializer)
786+ }
787+ }
788+ impl < ' de , A : ' static , Output : ' static > serde:: de:: Deserialize < ' de >
789+ for boxed:: Box < dyn for < ' r > FnOnce < ( & ' r A , ) , Output = Output > + Send + ' static >
790+ {
791+ fn deserialize < D > ( deserializer : D ) -> Result < Self , D :: Error >
792+ where
793+ D : serde:: Deserializer < ' de > ,
794+ {
795+ <Box < dyn for < ' r > FnOnce < ( & ' r A , ) , Output = Output > + Send + ' static > >:: deserialize (
796+ deserializer,
797+ )
798+ . map ( |x| x. 0 )
799+ }
800+ }
747801
748802/// A convenience trait implemented on all (de)serializable implementors of [`std::ops::FnMut`].
749803///
0 commit comments