forked from rust-postgres/rust-postgres
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenums.rs
More file actions
28 lines (24 loc) · 677 Bytes
/
Copy pathenums.rs
File metadata and controls
28 lines (24 loc) · 677 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use syn::{Error, Fields, Ident};
use crate::overrides::Overrides;
pub struct Variant {
pub ident: Ident,
pub name: String,
}
impl Variant {
pub fn parse(raw: &syn::Variant) -> Result<Variant, Error> {
match raw.fields {
Fields::Unit => {}
_ => {
return Err(Error::new_spanned(
raw,
"non-C-like enums are not supported",
))
}
}
let overrides = Overrides::extract(&raw.attrs)?;
Ok(Variant {
ident: raw.ident.clone(),
name: overrides.name.unwrap_or_else(|| raw.ident.to_string()),
})
}
}