您的位置:首页 > 其它

通过例子学习Rust之 1 Hello World

2015-06-25 17:25 375 查看
1 Hello World

世界,你好。

This is the source code of the traditional Hello World program.

这是传统的Hello World的源代码。

// This is a comment, and will be ignored by the compiler
// 本行为注释,会被编译器忽略
// You can test this code by clicking the "Run" button over there ->
// 点击Run按钮即可运行此代码
// or if prefer to use your keyboard, you can use the "Ctrl + Enter" shortcut
// 或者希望使用键盘,可以用"Ctrl + Enter"快捷键
// This code is editable, feel free to hack it!
// 点击此代码即可编辑
// You can always return to the original code by clicking the "Reset" button ->
// 随时点击"Reset"按钮回到初始代码
// 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! is a macro that prints text to the console.

println! 是一个向控制台打印文本的宏

A binary can be generated using the Rust compiler: rustc.

使用Rust编译器命令rustc即可生成二进制文件

$ rustc hello.rs

rustc will produce a hello binary that can be executed.

rustc 将产生一个可执行的二进制文件hello

$ ./hello

Hello World!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  rust helloworld