trpl-zh-cn/listings/ch04-understanding-ownership/listing-04-01/src/main.rs
2022-02-06 23:46:50 +08:00

9 lines
272 B
Rust
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

fn main() {
// ANCHOR: here
{ // s 在这里无效, 它尚未声明
let s = "hello"; // 从此处起s 是有效的
// 使用 s
} // 此作用域已结束s 不再有效
// ANCHOR_END: here
}