为什么学 Rust
Rust 连续多年被评为最受喜爱的编程语言。它在不牺牲性能的前提下,通过所有权系统在编译期消除了内存安全问题。
核心概念
所有权
let s1 = String::from("hello");
let s2 = s1; // s1 所有权转移
println!("{}", s2); // OK借用
fn len(s: &String) -> usize { s.len() }
let s = String::from("hello");
println!("长度: {}", len(&s));适用场景
- 系统编程
- WebAssembly
- 命令行工具
- 高性能网络服务
Rust 的学习曲线陡峭,但跨过去后会改变你对编程的思考方式。
— EOF —