rust-postgres/postgres-derive/src/composites.rs
2019-10-10 15:26:30 -07:00

23 lines
505 B
Rust

use syn::{Error, Ident, Type};
use crate::overrides::Overrides;
pub struct Field {
pub name: String,
pub ident: Ident,
pub type_: Type,
}
impl Field {
pub fn parse(raw: &syn::Field) -> Result<Field, Error> {
let overrides = Overrides::extract(&raw.attrs)?;
let ident = raw.ident.as_ref().unwrap().clone();
Ok(Field {
name: overrides.name.unwrap_or_else(|| ident.to_string()),
ident,
type_: raw.ty.clone(),
})
}
}