aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2016-11-17 05:38:41 -0800
committerAustin Hellyer <[email protected]>2016-11-17 05:38:41 -0800
commit772aeaf66eb7e0ae4edab5b9d7dfeecdce5bd3f7 (patch)
tree7e6b85765b223f0a4b734f70c15461dad640c092
parentAdd DELETE/PUT guild member role (diff)
downloadserenity-772aeaf66eb7e0ae4edab5b9d7dfeecdce5bd3f7.tar.xz
serenity-772aeaf66eb7e0ae4edab5b9d7dfeecdce5bd3f7.zip
Add a build decoder for u64s with a default
This will fix `ReadState`s failing to decode a `mention_count` if it is not present, as it may be optional. Default to `0`.
-rw-r--r--build.rs5
-rw-r--r--definitions/structs/read_state.yml2
2 files changed, 6 insertions, 1 deletions
diff --git a/build.rs b/build.rs
index 2ab0961..de4cbe0 100644
--- a/build.rs
+++ b/build.rs
@@ -361,6 +361,11 @@ impl {0} {{
from,
default.parse::<u64>().unwrap())
},
+ ("u64", false, false, Some(default), None, None, None) => {
+ format!(r#"try!(opt(&mut map, "{}", |v| Ok(req!(v.as_u64())))).unwrap_or({})"#,
+ field_name,
+ default.parse::<u64>().unwrap())
+ },
("u64", false, false, None, None, Some(from), None) => {
format!(r#"req!(try!(remove(&mut map, "{}")).as_u64())"#,
from)
diff --git a/definitions/structs/read_state.yml b/definitions/structs/read_state.yml
index 3e0c8cd..ef580b6 100644
--- a/definitions/structs/read_state.yml
+++ b/definitions/structs/read_state.yml
@@ -11,5 +11,5 @@ fields:
optional: true
type: string
- name: mention_count
- default: 0
+ default: '0'
type: u64