Skip to content

Instantly share code, notes, and snippets.

@MaikKlein
Created March 11, 2018 16:26
Show Gist options
  • Save MaikKlein/d36376ad0ff6246e1ef184cf85306b94 to your computer and use it in GitHub Desktop.
Save MaikKlein/d36376ad0ff6246e1ef184cf85306b94 to your computer and use it in GitHub Desktop.
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Constant {
pub name: String,
pub notation: Option<Notation>,
pub constant: ConstantEnum,
// Is there an enum representation for those options?
// pub number: Option<i32>,
// pub hex: Option<String>,
// pub bitpos: Option<u32>,
// pub c_expression: Option<CExpression>,
}
#[derive(Deserialize, Serialize, Debug)]
pub enum ConstantEnum {
#[serde(rename = "number")]
Number(i32),
#[serde(rename = "hex")]
Hex(String),
#[serde(rename = "bitpos")]
Bitpos(u32),
#[serde(rename = "c_expression")]
CExpression(CExpression)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment