这是传统的Hello World程序的源代码(Rust语言看就是这个样子)。
// This is the main function |
fn main() { |
// The statements here will be 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! |