I wrote about good type design in Rust.
It applies to any language with algebraic data types. (structs and enums) Please let me know what you think.
@bshankar I think if you have a function that takes an enum, and the function is only valid for some variants of the enum, then the type needs to be reworked. For example, if you used newtypes instead of enum variants, then you could tie the ones that are expected to have an email together with a trait. And then your function to update the email can be generic over the trait, and you no longer need to return Result there.
@bshankar I don't think the example is silly, I go through this exact progression all the time: Struct with bools or Options, fix it by switching to an enum, realize that my enum variants are really distinct types, switch to a trait-based solution. Some day I'll learn to skip to the end :)