不打印到终端上

问题描述 投票:0回答:2

使用println!时rustc不向终端输出任何东西。

代码:

fn main() {
   println!("Hello, world!");
}

正在运行:

me@mclaptop:~
> rustc helloworld.rs

me@mclaptop:~
>

为什么不打印任何内容?

rust
2个回答
1
投票

rustc仅编译您的代码。您需要调用输出二进制文件以使其正常工作。

尝试./helloworld或任何输出文件的名称。


1
投票

rustc是Rust语言的编译器,它只生成要运行的可执行文件。如果要实际查看输出,则必须运行./helloworld命令。

您可以阅读here

© www.soinside.com 2019 - 2024. All rights reserved.