Whenever someone writes bad things™ about some language, one of the language's fanboys shows up and starts nitpicking! Yes, now is the time! > Another bad part is Rust’s JSON handling. It badly needs macros which make things easier. Actually this is not the end of the world. As you mentioned, Rust's JSON library supports `ToJson` for primitive types, but also provides compile-time code generation for arbitrary `struc…
#[derive(RustcDecodable, RustcEncodable)]
enum Msg {
Basic { cmd: String, id: i32 },
Positioned { cmd: String, id: i32, x: i32, y: i32 },
Speed { cmd: String, id: i32, speed: i32 },
Full { cmd: String, id: i32, x: i32, y: i32, speed: i32 }
}
That would allow you to prevent weird cases like x being provided but y not being provided.