你好,世界

这是传统的“你好,世界”程序的源代码。

// This is a comment, and is ignored by the compiler.
// You can test this code by clicking the "Run" button over there ->
// or if you prefer to use your keyboard, you can use the "Ctrl + Enter"
// shortcut.

// This code is editable, feel free to hack it!
// You can always return to the original code by clicking the "Reset" button ->

// This is the main function.
fn main() {
    // Statements here are executed when the compiled binary is called.

    // Print text to the console.
    println!("Hello World!");
}

println! 是一个将文本打印到控制台的

可以使用 Rust 编译器生成二进制文件:rustc

$ rustc hello.rs

rustc 将生成一个可以执行的 hello 二进制文件。

$ ./hello
Hello World!

活动

点击上面的“运行”按钮查看预期输出。接下来,添加一个包含第二个 println! 宏的新行,以便输出显示

Hello World!
I'm a Rustacean!