Closed wiiznokes closed 10 months ago
Moreover, into
to take ownership of the variable while it seems unnecessary.
I'm forced to call NodeTypeDiscriminants::from(&node.node_type)
Hey @wiiznokes, naming things is hard so I try to avoid inherent methods on types. There's an infinite number of valid/useful names, I try to use the built-in traits from the standard library and then allow people to add their own inherent methods on top of it if they want to. It's not ideal, but it's the best compromise I can find between flexibility and causing a combinatorial explosion in the api surface of this crate.
I don't understand why I can't convert my enum into a discriminant. Here is the code:
So, why not make an helper function, like
node_type.to_discriminant()
? This will be a little more descriptive thaninto()
, and will provide a similar alternative tointo()
in case of compiler problems.