которая возвращает футуру?
                  
                  
                  
                  
                  
                  То есть что-то типо 
                  
                  
                  on_ws_message: Option<Box<dyn Sync + Send + Fn(Message) -> Box<dyn Future<Output = Result<(), anyhow::Error>> + Send + Sync>>>
                  
                  
                  проблема в том, что когда я пытаюсь добавить эту кложу таким способом -
                  
                  
                  pub async fn on_ws_message<Cl, F>(&mut self, f: Cl) -> &mut Self
                  
                  
                  where
                  
                  
                      Cl: 'static + Send + Sync + Fn(Message) -> F,
                  
                  
                      F: 'static + Send + Sync + Future<Output = Result<(), anyhow::Error>>
                  
                  
                  {
                  
                  
                      self.cb_ctx.lock().await.on_ws_message = Some(Box::new(&f));
                  
                  
                      self
                  
                  
                  }
                  
                  
                  вылезает такой еррор -
                  
                  
                  
                  
                  
                  64 |         self.cb_ctx.lock().await.on_ws_message = Some(Box::new(&f));
                  
                  
                     |                                                       ^^^^^^^^^^^^ expected struct `std::boxed::Box`, found type parameter `F`
                  
                  
                     |
                  
                  
                     = note:      expected struct `std::boxed::Box<dyn core::future::future::Future<Output = std::result::Result<(), anyhow::Error>> + std::marker::Send + std::marker::Sync>`
                  
                  
                             found type parameter `F`
                  
                  
                
Box::new(f) без &
Обсуждают сегодня