mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-29 19:47:38 +00:00
23 lines
709 B
Rust
23 lines
709 B
Rust
![]() |
struct Website {
|
||
|
url: String,
|
||
|
title: Option<String> ,//~ NOTE defined here
|
||
|
}
|
||
|
|
||
|
fn main() {
|
||
|
let website = Website {
|
||
|
url: "http://www.example.com".into(),
|
||
|
title: Some("Example Domain".into()),
|
||
|
};
|
||
|
|
||
|
if let Website { url, Some(title) } = website { //~ ERROR expected `,`
|
||
|
//~^ NOTE while parsing the fields for this pattern
|
||
|
println!("[{}]({})", title, url); // we hide the errors for `title` and `url`
|
||
|
}
|
||
|
|
||
|
if let Website { url, .. } = website { //~ NOTE `Website` has a field `title`
|
||
|
//~^ NOTE this pattern
|
||
|
println!("[{}]({})", title, url); //~ ERROR cannot find value `title` in this scope
|
||
|
//~^ NOTE not found in this scope
|
||
|
}
|
||
|
}
|