Add generic type to remote derive example

This commit is contained in:
Graham Esau 2019-12-27 16:25:50 +00:00
parent be92d4da5f
commit e25791dddf
4 changed files with 20 additions and 0 deletions

View file

@ -31,6 +31,9 @@ pub struct Process {
pub command_line: String,
#[serde(with = "DurationDef")]
pub wall_time: Duration,
// Generic types must be explicitly specified with turbofix `::<>` syntax.
#[serde(with = "Vec::<DurationDef>")]
pub durations: Vec<Duration>,
}
fn main() {

View file

@ -4,12 +4,19 @@
"type": "object",
"required": [
"command_line",
"durations",
"wall_time"
],
"properties": {
"command_line": {
"type": "string"
},
"durations": {
"type": "array",
"items": {
"$ref": "#/definitions/Duration"
}
},
"wall_time": {
"$ref": "#/definitions/Duration"
}

View file

@ -31,6 +31,9 @@ pub struct Process {
pub command_line: String,
#[serde(with = "DurationDef")]
pub wall_time: Duration,
// Generic types must be explicitly specified with turbofix `::<>` syntax.
#[serde(with = "Vec::<DurationDef>")]
pub durations: Vec<Duration>,
}
fn main() {

View file

@ -4,12 +4,19 @@
"type": "object",
"required": [
"command_line",
"durations",
"wall_time"
],
"properties": {
"command_line": {
"type": "string"
},
"durations": {
"type": "array",
"items": {
"$ref": "#/definitions/Duration"
}
},
"wall_time": {
"$ref": "#/definitions/Duration"
}