Hello World!
让我们进入最简单的 Rust 程序,一个经典的 Hello World 程序:
fn main() { println!("Hello 🌍!"); }
你看到的:
- 函数以
fn
开头。 - 像 C 和 C++ 一样,块由花括号分隔。
main
函数是程序的入口。- Rust 有卫生宏 (hygienic macros),
println!
就是一个例子。 - Rust 字符串是 UTF-8 编码的,可以包含任何 Unicode 字符。
This slide tries to make the students comfortable with Rust code. They will see a ton of it over the next three days so we start small with something familiar.
关键点: