From c47ed815b6d732891042d5285b5c36c4041dfbf9 Mon Sep 17 00:00:00 2001 From: hodasemi Date: Thu, 11 Apr 2024 13:35:44 +0200 Subject: [PATCH] Add as fn trait function --- src/states.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/states.rs b/src/states.rs index ff4e54b..4f79763 100644 --- a/src/states.rs +++ b/src/states.rs @@ -11,6 +11,13 @@ pub trait FutureStateChange: Fn() -> Result<()> + Send + Sync { fn clone_box<'a>(&self) -> Box where Self: 'a; + + fn as_fn(&self) -> &(dyn Fn() -> Result<()> + Send + Sync) + where + Self: Sized, + { + self + } } impl Result<()> + Clone + Send + Sync> FutureStateChange for F {