Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

options3 ref vs & #1720

Open
eyyyyyyy3 opened this issue Oct 14, 2023 · 0 comments
Open

options3 ref vs & #1720

eyyyyyyy3 opened this issue Oct 14, 2023 · 0 comments

Comments

@eyyyyyyy3
Copy link

eyyyyyyy3 commented Oct 14, 2023

Why is this way of solving the challenge:

`fn main() {
let y: Option = Some(Point { x: 100, y: 200 });

match y {
    Some(ref p) => println!("Co-ordinates are {},{} ", p.x, p.y),
    _ => panic!("no match!"),
}
y; // Fix without deleting this line.

}`

more preferred than this one:
`fn main() {
let y: Option = Some(Point { x: 100, y: 200 });

match &y {
    Some(p) => println!("Co-ordinates are {},{} ", p.x, p.y),
    _ => panic!("no match!"),
}
y; // Fix without deleting this line.

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant