← 返回卡片

原书出处

Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)

03 Ownership and Moves 保持集合有效地取得元素所有权

Third Edition (First Early Release) · 核验版本的摘录快照 · 导入于 2026-11-25T08:54:22.911Z

field from String to Option<String>, that means that

None is a legitimate value for the field to hold, so this works:

let first_name = std::mem::replace(&mut composers[0].name, None); assert_eq!(first_name, Some("Palestrina".to_string()));

此预览只包含定位所需的摘录和上下文。

原书定位详情

来源:a19c7933-4eda-4176-aebd-30fe7e1ad292

正文位置:extracted/Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)/_epub-src/OEBPS/ch03.xhtml#moves-and-indexed-content

EPUB SHA-256:5d6262f270165cb632e9ad57285ce4a93e9881b44818eebe90bdaa1c2f23a899