Mapping returned `Result` of main to an exit code?

⚓ rust    📅 2025-05-25    👤 surdeus    👁️ 3      

surdeus

Warning

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

The signature of my main function is fn main()->Result<(), Box<dyn std::error::Error>>.

However for different returned Errors, the exit code are all 1. And for Ok(()), the exit code is surely 0.

I know that there IS a method that can do this mapping, based on std::process::exit.

But is there a better way to do this?

2 posts - 2 participants

Read full topic

🏷️ rust_feed