Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
hurril
on Sept 22, 2023
|
parent
|
context
|
favorite
| on:
Using enums to represent state in Rust
Then what does this mean?
let x: u8 = E::Rest(0).into();
let y: E = x.into();
duped
on Sept 22, 2023
[–]
Bad example, that should panic (in a perfect world it should be a compile error). The invariant of the type is that `E::Rest` cannot hold zero.
hurril
on Sept 22, 2023
|
parent
[–]
Why is that a bad example? It's proof that implementing From does not solve the problem.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
let x: u8 = E::Rest(0).into();
let y: E = x.into();