Hello Rust
- Code
- 主函数
main- 声明
fn
- 声明
- 语句结尾
; - 宏
macroprintln!打印文本
- 主函数
// main 没有参数、没有返回值、是每个rust可执行程序最新运行的代码
fn main() {
// 打印文本
// println! 属于 Rust macro 宏定义
// 正常来说函数是没有 感叹号的
println!("Hello World");
}
- Compile
ahead-of-time先编译后执行rustc编译rustc 原文件名- 尽适合简单几个文件的编译
$ rustc hello-world.rs
$ ls
hello-world hello-world.rs
- Run
$ ./hello-world
Hello World
关于 LearnKu
推荐文章: