发布于 2015-07-16 14:07:01 | 378 次阅读 | 评论: 0 | 来源: 网络整理

Rust第一个程序 Hello World

这是传统的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!
最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务