为什么Rust在main函数中没有返回值,以及无论如何如何返回值? [英] Why does Rust not have a return value in the main function, and how to return a value anyway?
本文介绍了为什么Rust在main函数中没有返回值,以及无论如何如何返回值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Rust中,主要功能的定义如下:
In Rust the main function is defined like this:
fn main() {
}
尽管此函数不允许返回值.为什么一种语言不允许返回值,并且仍然有一种方法可以返回任何值?我可以安全地使用 C exit(int)
函数,还是会导致泄漏等等?
This function does not allow for a return value though. Why would a language not allow for a return value and is there a way to return something anyway? Would I be able to safely use the C exit(int)
function, or will this cause leaks and whatnot?
推荐答案
查看全文