Returning early from a function I'm in, from inside a closure

⚓ Rust    📅 2026-02-24    👤 surdeus    👁️ 2      

surdeus

Hi folks, I'm facing difficulties returning early from my function, while inside a closure, passed to a library function I call.

Here is the library function docs: invoke_from_event_loop in slint - Rust,
this is the signature:

pub fn invoke_from_event_loop(
    func: impl FnOnce() + Send + 'static,
) -> Result<(), EventLoopError> 

Here an example usage:

slint::invoke_from_event_loop(move || handle_copy.unwrap().set_foo(foo)); ()

My Q is, given the example above, how to propagate the error from handle_copy, instead of .unwrap()ing it? The closure shall return EventLoopError in case of failure, however that's not a suitable error type for my situation, where I parse stuff.
Thank you!

3 posts - 3 participants

Read full topic

🏷️ Rust_feed