What's the best way to return Result<(), _>?
⚓ Rust 📅 2026-01-23 👤 surdeus 👁️ 1I am creating a program in which main returns Result<(), _>, and I was wondering: what's the best - or rather, most semantic - way to return Ok(())? Should it be as in:
fn main() -> Result<(), std::io::Error> {
Ok(foo())
}
or as in
fn main() -> Result<(), std::io::Error> {
foo();
Ok(())
}
Or is there some other layer to this that I am completely missing?
Thanks!
6 posts - 6 participants
🏷️ Rust_feed