feat(codegen): Allow #[serde(default="123")]

This feature adds support for the default to be specified to be
some expression (which unfortunately needs to be parsed from
a string) without needing this value to have an implementation
of `Default`, or for a new-type wrapper in order to provide an
alternative implementation. This expression is run in a function,
and therefore has no access to any of the internal state of
the deserializer.
This commit is contained in:
Erick Tryzelaar
2016-02-12 21:53:35 -08:00
parent 8ea6c66cf7
commit 9812a4c9c6
4 changed files with 184 additions and 41 deletions
+1 -1
View File
@@ -605,7 +605,7 @@ fn serialize_struct_visitor<I>(
{
let value_exprs = value_exprs.collect::<Vec<_>>();
let field_attrs = try!(attr::get_struct_field_attrs(cx, fields));
let field_attrs = try!(attr::get_struct_field_attrs(cx, generics, fields));
let arms: Vec<ast::Arm> = field_attrs.iter()
.zip(value_exprs.iter())