Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: How do i return a value from a thread func
i 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