One last refactor
This commit is contained in:
parent
e3f64b1892
commit
562778f61d
@ -40,7 +40,7 @@ impl ActiveEnum {
|
|||||||
let mut db_type = Err(Error::TT(quote_spanned! {
|
let mut db_type = Err(Error::TT(quote_spanned! {
|
||||||
ident_span => compile_error!("Missing macro attribute `db_type`");
|
ident_span => compile_error!("Missing macro attribute `db_type`");
|
||||||
}));
|
}));
|
||||||
let mut rename_all_rule = None;
|
let mut rename_all = None;
|
||||||
|
|
||||||
input
|
input
|
||||||
.attrs
|
.attrs
|
||||||
@ -72,7 +72,7 @@ impl ActiveEnum {
|
|||||||
let litstr: LitStr = meta.value()?.parse()?;
|
let litstr: LitStr = meta.value()?.parse()?;
|
||||||
enum_name = litstr.value();
|
enum_name = litstr.value();
|
||||||
} else if meta.path.is_ident("rename_all") {
|
} else if meta.path.is_ident("rename_all") {
|
||||||
rename_all_rule = Some((&meta).try_into()?);
|
rename_all = Some((&meta).try_into()?);
|
||||||
} else {
|
} else {
|
||||||
return Err(meta.error(format!(
|
return Err(meta.error(format!(
|
||||||
"Unknown attribute parameter found: {:?}",
|
"Unknown attribute parameter found: {:?}",
|
||||||
@ -89,7 +89,7 @@ impl ActiveEnum {
|
|||||||
_ => return Err(Error::InputNotEnum),
|
_ => return Err(Error::InputNotEnum),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut is_string = rename_all_rule.is_some();
|
let mut is_string = rename_all.is_some();
|
||||||
let mut is_int = false;
|
let mut is_int = false;
|
||||||
let mut variants = Vec::new();
|
let mut variants = Vec::new();
|
||||||
|
|
||||||
@ -135,9 +135,7 @@ impl ActiveEnum {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if string_value.is_none()
|
if string_value.is_none() && num_value.is_none() && rename_rule.or(rename_all).is_none()
|
||||||
&& num_value.is_none()
|
|
||||||
&& rename_rule.or(rename_all_rule).is_none()
|
|
||||||
{
|
{
|
||||||
match variant.discriminant {
|
match variant.discriminant {
|
||||||
Some((_, Expr::Lit(exprlit))) => {
|
Some((_, Expr::Lit(exprlit))) => {
|
||||||
@ -191,7 +189,7 @@ impl ActiveEnum {
|
|||||||
db_type: db_type?,
|
db_type: db_type?,
|
||||||
is_string,
|
is_string,
|
||||||
variants,
|
variants,
|
||||||
rename_all: rename_all_rule,
|
rename_all,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user