You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is troublesome for long structs, as there is no indicator of where or why the panic is occurring. This is a misuse of the default parameter, but it would be nice if there was an error to guide you to the correct usage.
Ideally, it'd be nice if you could use an unquoted parameter for symbols and a quoted parameter for strings. Alas, it's probably too late for this.
Example:
#[macro_use]
extern crate serde_derive;
extern crate serde;
enum Enum {
A,
B,
}
#[derive(Deserialize)]
struct A {
#[serde(default=E::A)]
a: E,
}
fn main() {
println!("Hello, world!");
}
Output:
Compiling playground v0.0.1 (file:///playground)
error: proc-macro derive panicked
--> src/main.rs:10:10
|
10 | #[derive(Deserialize)]
| ^^^^^^^^^^^
|
= help: message: called `Result::unwrap()` on an `Err` value: "failed to parse derive input: \"struct A {\\n #[serde\\n ( default = E :: A )]\\n a: E,\\n}\""
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
The text was updated successfully, but these errors were encountered:
There are two issues here: default=E::A fails to parse and default=E::A is not supported as a way of specifying the default value for an enum field. The first one will be fixed when we pick up the next release of syn, which supports arbitrary content in an attribute rust-lang/rust#34981. The second one I would prefer to track along with #368 -- I left a comment there. Thanks!
This is troublesome for long structs, as there is no indicator of where or why the panic is occurring. This is a misuse of the default parameter, but it would be nice if there was an error to guide you to the correct usage.
Ideally, it'd be nice if you could use an unquoted parameter for symbols and a quoted parameter for strings. Alas, it's probably too late for this.
Example:
Output:
The text was updated successfully, but these errors were encountered: