Hacker News new | past | comments | ask | show | jobs | submit login

Did you look at the if let syntax?

  if let Bar::Qux(x) = foo { ... )



It looks like they want to panic if the variant is not what they expect. Basically implement their own unwrap() for their own enum, since the above logic is basically what Option::unwrap() does for Option::Some.

Assuming there's not some wider design issue, I'd probably implement an unwrap_qux() method on the Bar enum




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: