创建并编辑文本文件hello_world.rs
fn main(){
let s = "hello world!";
println!("{}", s);
}
用rustc编译,生成hello_world的可执行文件
rustc hello_world.rs
./hello_world
- 一般Rust源代码的后缀名使用.rs表示。源码一定要使用utf-8编码
- 注释使用//或/**/
- main函数是可执行程序的入口
创建并编辑文本文件hello_world.rs
fn main(){
let s = "hello world!";
println!("{}", s);
}
用rustc编译,生成hello_world的可执行文件
rustc hello_world.rs
./hello_world