Update main.rs
@ -3,7 +3,7 @@ fn main() {
{
let v = vec![1, 2, 3, 4];
// do stuff with v
// 使用 v
} // <- v goes out of scope and is freed here
} // <- 在这里 v 离开作用域并被释放
// ANCHOR_END: here
}
@ -77,7 +77,7 @@
如果 `push_str` 方法获取了 `s2` 的所有权,就不能在最后一行打印出其值了。好在代码如我们期望那样工作!
`push` 方法被定义为获取一个单独的字符作为参数,并附加到 `String` 中。示例 8-17 展示了使用 `push` 方法将字母 *l* 加入 `String` 的代码。
`push` 方法被定义为获取一个单独的字符作为参数,并附加到 `String` 中。示例 8-17 展示了使用 `push` 方法将字母 `l` 加入 `String` 的代码。
```rust
{{#rustdoc_include ../listings/ch08-common-collections/listing-08-17/src/main.rs:here}}