使用println!
时rustc不向终端输出任何东西。
代码:
fn main() {
println!("Hello, world!");
}
正在运行:
me@mclaptop:~
> rustc helloworld.rs
me@mclaptop:~
>
为什么不打印任何内容?
rustc
仅编译您的代码。您需要调用输出二进制文件以使其正常工作。
尝试./helloworld
或任何输出文件的名称。
rustc
是Rust语言的编译器,它只生成要运行的可执行文件。如果要实际查看输出,则必须运行./helloworld
命令。
您可以阅读here。