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, pub command_line: String,
#[serde(with = "DurationDef")] #[serde(with = "DurationDef")]
pub wall_time: Duration, pub wall_time: Duration,
// Generic types must be explicitly specified with turbofix `::<>` syntax.
#[serde(with = "Vec::<DurationDef>")]
pub durations: Vec<Duration>,
} }
fn main() { fn main() {

View file

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

View file

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

View file

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