Gitlab updates will be applied at 1:30pm, (17:30 UTC), today. No downtime expected.

Commit 45aadb02 authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'deserialize-multi-choice'

2199ef3a macros: support multiple choices for deserializing strings
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Reviewed-by: Brad King's avatarBrad King <brad.king@kitware.com>
Merge-request: !99
parents 754f0bd0 2199ef3a
Pipeline #64469 passed with stage
in 0 seconds
......@@ -36,7 +36,7 @@ macro_rules! impl_id {
}
macro_rules! enum_serialize {
( $name:ident -> $desc:expr, $( $value:ident => $str:expr, )+ ) => {
( $name:ident -> $desc:expr, $( $value:ident => $str:expr $( ; $opt:expr )*, )+ ) => {
impl $name {
/// String representation of the variant.
pub fn as_str(&self) -> &'static str {
......@@ -61,7 +61,7 @@ macro_rules! enum_serialize {
let val = String::deserialize(deserializer)?;
match val.as_str() {
$( $str => Ok($name::$value), )*
$( $str $( | $opt )* => Ok($name::$value), )*
v => {
error!(target: "gitlab", concat!("unknown ", $desc, " from gitlab: {}"), v);
Err(D::Error::invalid_value(Unexpected::Other("enumeration value"),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment