Skip to content

Commit

Permalink
One last refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tyt2y3 committed May 29, 2024
1 parent e3f64b1 commit 562778f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions sea-orm-macros/src/derives/active_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl ActiveEnum {
let mut db_type = Err(Error::TT(quote_spanned! {
ident_span => compile_error!("Missing macro attribute `db_type`");
}));
let mut rename_all_rule = None;
let mut rename_all = None;

input
.attrs
Expand Down Expand Up @@ -72,7 +72,7 @@ impl ActiveEnum {
let litstr: LitStr = meta.value()?.parse()?;
enum_name = litstr.value();
} else if meta.path.is_ident("rename_all") {
rename_all_rule = Some((&meta).try_into()?);
rename_all = Some((&meta).try_into()?);
} else {
return Err(meta.error(format!(
"Unknown attribute parameter found: {:?}",
Expand All @@ -89,7 +89,7 @@ impl ActiveEnum {
_ => 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 variants = Vec::new();

Expand Down Expand Up @@ -135,9 +135,7 @@ impl ActiveEnum {
}));
}

if string_value.is_none()
&& num_value.is_none()
&& rename_rule.or(rename_all_rule).is_none()
if string_value.is_none() && num_value.is_none() && rename_rule.or(rename_all).is_none()
{
match variant.discriminant {
Some((_, Expr::Lit(exprlit))) => {
Expand Down Expand Up @@ -191,7 +189,7 @@ impl ActiveEnum {
db_type: db_type?,
is_string,
variants,
rename_all: rename_all_rule,
rename_all,
})
}

Expand Down

0 comments on commit 562778f

Please sign in to comment.