Closed
Description
For example:
#[deriving(Decodable)]
struct Duration(int);
The decodable
implementation created here tries to decode an object with a field named _field0
and of type int
, like { "_field0": 5 }
There two problems with this:
- Most people won't expect this behavior (I would expect this code to decode a single int, not an object)
- The fact that the field name is arbitrary makes this trait impl useless anyway
I think that the deriving implementation of decodable
for structs with one anonymous field should be equivalent to decoding the type of the field itself.
Structs with multiple anonymous fields are ambiguous, so I think deriving decodable for them should simply trigger a compilation error.