How do i return a value from a thread func
⚓ Rust 📅 2025-09-07 👤 surdeus 👁️ 9i want to return Result<String,Box<dyn Error>> from a function that i pass to a thread spawn
pub fn launch_app(command: &String) -> Result<String, Box<dyn Error>> {
let output = Command::new("sh").arg("-c").arg(command).output()?.stdout;
let cmd_output = String::from_utf8(output)?;
Ok(cmd_output)
}
What will be the best way to do so ?
6 posts - 3 participants
🏷️ Rust_feed