As discussed in #219, decoding the "enum-like" fields from the API types has some problems
- Incurs unwarranted parsing errors due to untracked variants
- Adds extra burden to keep up with the API variants whenever Github decides to change it
#244 suggests a less error-prone interface like the following
enum EventAction {
Foo
}
struct Event {
action: String // String instead of EventAction; purposefully private
}
impl Event {
pub fn is_action(&self, action: EventAction) -> bool {
self.action == action.to_string()
}
}
Using [variant].to_string() is less error-prone than working with literal strings since the latter is subject to typos.
As discussed in #219, decoding the "enum-like" fields from the API types has some problems
#244 suggests a less error-prone interface like the following
Using
[variant].to_string()is less error-prone than working with literal strings since the latter is subject to typos.