mirror of https://github.com/sunface/rust-course
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
386 B
20 lines
386 B
3 years ago
|
// option3.rs
|
||
3 years ago
|
// 让我通过编译!执行 `rustlings hint option3` 获取提示
|
||
3 years ago
|
|
||
|
// I AM NOT DONE
|
||
|
|
||
|
struct Point {
|
||
|
x: i32,
|
||
|
y: i32,
|
||
|
}
|
||
|
|
||
|
fn main() {
|
||
|
let y: Option<Point> = Some(Point { x: 100, y: 200 });
|
||
|
|
||
|
match y {
|
||
|
Some(p) => println!("Co-ordinates are {},{} ", p.x, p.y),
|
||
|
_ => println!("no match"),
|
||
|
}
|
||
3 years ago
|
y; // 无需删除这行就可以解决。
|
||
3 years ago
|
}
|