Enums are very useful in structures that represents forms, particularly as parses of radio and option fields. For example, if the HTML forms contains:
<label>Select:
<select name="select">
<option value="a">Value A</option>
<option value="b" selected>Value B</option>
<option value="c">Value C</option>
</select>
</label>
It would be nice to parse the select field as an enum:
enum SelectValue {
A, B, C
}
In this example, "a" or "A" would parse as SelectValue::A, etc.
At present, Rocket does not support deriving FromFormValue for any types. It would be nice to extend Rocket to automatically implement FromFormValue to cover enums with nullary fields with an implementation as shown above.
This isn't particularly important or necessary. Let's push this to 0.4.0, and we'll get it sooner if possible.
I have completed an implementation of this feature. Pushing the changes will require a restructuring of the codegen code to allow for proc_macros. Once that restructuring is complete, I will push the implementation and close this issue.
Most helpful comment
I have completed an implementation of this feature. Pushing the changes will require a restructuring of the
codegencode to allow forproc_macros. Once that restructuring is complete, I will push the implementation and close this issue.