Run a function with !send value and return immediately

⚓ rust    📅 2025-05-23    👤 surdeus    👁️ 4      

surdeus

Warning

This post was published 37 days ago. The information described in this article may have changed.

Hi,

I need to run a function or future (I can make it both). The function takes non send value. I can not wait this function to finish or can't schedule it later. I have to return immediately.

tokio::spawn(async {
   if let Ok(non_send_value) = function_a().await {
      function_that_takes_non_send_value_and_takes_a_lot_of_time_to_finish(non_send_value)
   }
   
  return true; // need to return this immediately
})

2 posts - 2 participants

Read full topic

🏷️ rust_feed