4
嵌套解构 - 夜雨秋灯录
source link: https://privaterookie.github.io/notes/rust/2021-10-31-%E5%B5%8C%E5%A5%97%E8%A7%A3%E6%9E%84.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
夜雨秋灯录
嵌套结构
rust 支持嵌套解构
pub enum Inner {
A(i32),
B(u32)
}
pub enum Outer {
Span,
P(Inner)
}
fn main() {
let x = Outer::P(Inner::A(12));
if let Outer::P(Inner::A(i)) = x {
println!("{}", i);
}
}
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK