pub fn spawn_local<Fut>(future: Fut) -> Task<Fut::Output>where
Fut: Future + 'static,Expand description
Creates a new thread-local task that runs on the main thread.
This function is designed for futures that are not Send and must execute
on the main thread.
§Arguments
future- The non-Send future to execute on the main thread
§Returns
A Task handle that can be awaited to retrieve the result
§Panics
This function may panic if not called from a main thread
§Examples
use native_executor::spawn_local;
use std::rc::Rc;
// Rc is not Send, so we need spawn_local
let local_data = Rc::new(42);
let task = spawn_local(async move {
*local_data + 58
});