Commit Graph

1717 Commits

Author SHA1 Message Date
Thomas de Zeeuw
9444db5f19 Add support for #[serde(default)] on structs
This allows structs to use the default value for each field defined in
the struct’s `std::default::Default` implementation, rather then the
default value for the field’s type.

```
struct StructDefault {
    a: i32,
    b: String,
}

impl Default for StructDefault {
    fn default() -> StructDefault {
        StructDefault{
            a: 100,
            b: "default".to_string(),
        }
    }
}
```

The code above will now return `100` for field `a` and `”default”` for
`b`, rather then `0` and `””` respectively.
2017-02-20 22:35:31 +01:00
David Tolnay
3bf8cda994
Update generics handling to use split_for_impl 2017-02-20 13:04:40 -08:00
David Tolnay
f98e7f6ba0 Merge pull request #778 from SimonSapin/serialize_display_bounded_length
Avoid some string allocations.
2017-02-20 11:09:32 -08:00
Simon Sapin
772b22b427 Avoid some string allocations. 2017-02-20 18:36:38 +01:00
David Tolnay
535ab1e04b
Merge pull request #771 from elliottslaughter:internally_content_tagged 2017-02-19 16:08:49 -08:00
David Tolnay
a3fe03c323
Serialization of Haskell style enums 2017-02-19 16:04:39 -08:00
David Tolnay
7dad6426da Merge pull request #774 from nox/limit-hints
Clamp hints coming from untrusted input to 4096
2017-02-19 13:51:21 -08:00
David Tolnay
792a5f7502
Also clamp the collection impls 2017-02-19 13:47:05 -08:00
Anthony Ramine
a4c738a9f3 Clamp hints coming from untrusted input to 4096 2017-02-19 14:29:41 +01:00
Elliott Slaughter
4538143d00 Initial work to support serialization of adjacently tagged enums. 2017-02-18 20:46:37 -08:00
David Tolnay
7f08894a32
Remove dependency on unneeded syn feature 2017-02-17 21:01:42 -08:00
David Tolnay
adf7b086b5
Remove outdated comment 2017-02-17 20:38:50 -08:00
David Tolnay
c590df13b9
Add compile-fail test for the with attribute 2017-02-16 18:43:04 -08:00
Oliver Schneider
afa6dfbbe2 Merge pull request #765 from serde-rs/with
Pair serialize_with and deserialize_with into one attribute
2017-02-15 08:33:14 +01:00
David Tolnay
f500db6e91
Pair serialize_with and deserialize_with into one attribute 2017-02-14 17:36:50 -08:00
David Tolnay
090c8a7049 Merge pull request #762 from serde-rs/rustfmt
Use rustfmt
2017-02-13 01:29:25 -08:00
David Tolnay
e8651a52e7
Rustfmt 2017-02-12 22:15:59 -08:00
David Tolnay
964a2dd4d1
Release 0.9.7 2017-02-09 17:52:11 -08:00
David Tolnay
8a21bbc720 Merge pull request #755 from serde-rs/playground
Playground feature to get serde_derive picked up by integer32 playground
2017-02-09 17:50:39 -08:00
Oliver Schneider
4dba260ad7 Merge pull request #756 from shepmaster/patch-2
Add missing close backtick
2017-02-09 18:01:35 +01:00
Jake Goulding
1d3044fa28 Add missing close backtick 2017-02-09 11:53:12 -05:00
David Tolnay
d1f0112bfb
Playground feature to get serde_derive picked up by integer32 playground 2017-02-08 12:37:40 -08:00
David Tolnay
3f25cd9a7e
No longer need ser::Error import 2017-02-08 08:17:43 -08:00
David Tolnay
45a36f1219
Fix proc macro panic message in tests 2017-02-08 08:12:32 -08:00
David Tolnay
529a1cfedb
Keyword no_std for serde and serde_derive 2017-02-08 07:40:02 -08:00
David Tolnay
219abd2e00
The performance is identical 2017-02-04 19:04:29 -08:00
David Tolnay
4bd10528a0 Merge pull request #736 from nox/serialize-iter
Introduce collect_seq and collect_map
2017-02-04 11:18:36 -08:00
David Tolnay
b82bba2d0a Merge pull request #747 from serde-rs/phantom_tags
Content clean-up
2017-02-04 08:53:04 -08:00
Anthony Ramine
17c175a1a6 Use specialisation to optimise collect_seq and collect_map 2017-02-04 12:22:58 +01:00
Anthony Ramine
763ab9c2a1 Use serialize_seq! to implement Serialize for [T] 2017-02-04 12:21:45 +01:00
Anthony Ramine
30b8036efa Remove ser::Iterator 2017-02-04 12:17:25 +01:00
Anthony Ramine
89bb16da6b Introduce Serializer::collect_map 2017-02-04 11:49:53 +01:00
Anthony Ramine
d00a895902 Introduce Serializer::collect_seq
This function serializes the given iterator as a sequence. Its iter parameter
has type I: IntoIterator, <I as IntoIterator>::Item: Serialize, which means it
will work both for iterators passed by value, therefore consuming them, and as
the value for a #[serde(serialize_with)] attribute, where it will be called as
Serializer::collect_seq(&self.field, serializer), relying on the common practice
of implementing IntoIterator for &C where C is a data type representing some
kind of collection.
2017-02-04 11:49:34 +01:00
Oliver Schneider
393b19ee8a update codegen to the content changes 2017-02-04 10:37:50 +01:00
Oliver Schneider
e68888d475 remove possible sublte ambiguity with .into_deserializer 2017-02-04 10:00:04 +01:00
David Tolnay
d1306a78ec
Release 0.9.6 2017-02-03 08:02:47 -08:00
David Tolnay
ce230adf12 Merge pull request #739 from serde-rs/tag
Untagged and internally tagged enums
2017-02-03 07:50:26 -08:00
David Tolnay
066c9a15cf
Explain status of content module 2017-02-03 07:43:04 -08:00
Oliver Schneider
6277079152 move the PhantomData usage to the Deserializer 2017-02-03 15:02:40 +01:00
Oliver Schneider
d60fd84b7e Merge pull request #740 from serde-rs/enumset
Remove the EnumSet impls
2017-02-03 13:38:39 +01:00
David Tolnay
02e6c04e9f
Check for sequence end 2017-02-02 22:13:32 -08:00
David Tolnay
9f04b9d6e7
Remove the EnumSet impls 2017-02-02 19:13:55 -08:00
David Tolnay
d298da0b4f
Require std for deserializing untagged enums 2017-02-02 19:09:38 -08:00
David Tolnay
ff21d557c7
Untagged and internally tagged enums 2017-02-02 18:48:30 -08:00
Oliver Schneider
faaa494579 Merge pull request #738 from serde-rs/absolute
Use absolute paths to Ok, Err, and other types and methods
2017-02-02 08:16:51 +01:00
David Tolnay
661cdf4e00
Inline the trait docs at the top level 2017-02-01 12:58:24 -08:00
David Tolnay
a55d812441
Even more absolute paths 2017-02-01 12:12:39 -08:00
David Tolnay
b7ca574bb3
Use absolute paths to Ok and Err 2017-02-01 09:42:12 -08:00
David Tolnay
d960571439
Release 0.9.5 2017-02-01 01:01:06 -08:00
David Tolnay
1ccc58e2aa Merge pull request #735 from serde-rs/travis
Allow running travis build locally
2017-02-01 00:43:27 -08:00