Why does Rust not have a return value in the main function, and how to return a value anyway?

前端 未结 5 1592
难免孤独
难免孤独 2021-02-02 07:38

In Rust the main function is defined like this:

fn main() {

}

This function does not allow for a return value though. Why would a language not

5条回答
  •  醉话见心
    2021-02-02 08:05

    As was noted by others, std::process::exit(code: i32) is the way to go here

    More information about why is given in RFC 1011: Process Exit. Discussion about the RFC is in the pull request of the RFC.

提交回复
热议问题