Serde: `#[derive(Serialize)]` with type defaults?

Created on 21 Sep 2015  路  3Comments  路  Source: serde-rs/serde

I have some code like this:

trait MyTrait: Debug + Serialize {}

#[derive(Serialize)]
struct MyStruct<T, U: MyTrait = i32> { t: T, u: U }

Which errors out with the message "error: associated type bindings are not allowed here".
The full error is here: https://gist.github.com/pwoolcoc/b94407ed648a125969f3, and I have an example project at https://github.com/pwoolcoc/serde-associated-types-bug


rustc 1.5.0-nightly (0418a43fa 2015-09-21)
binary: rustc
commit-hash: 0418a43fa3ce430d18e87c66afb2185395f354d6
commit-date: 2015-09-21
host: x86_64-unknown-linux-gnu
release: 1.5.0-nightly
cargo 0.6.0-nightly (4080ea8 2015-09-20)
bug derive

Most helpful comment

Fixed in #295, this can be closed.

All 3 comments

Nice find! I need to add support for this.

I have a fix at https://github.com/dtolnay/serde/commit/fdc81dbb4a344b7135c162d7be47f715afd65c28 but it conflicts with #285, so I will wait for that to merge before opening a PR.

Fixed in #295, this can be closed.

Was this page helpful?
0 / 5 - 0 ratings