rust/tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
709 B
Rust
Raw Normal View History

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
}
}