Skip to content

Commit

Permalink
Add comment explaining why we double-parse an Expr
Browse files Browse the repository at this point in the history
  • Loading branch information
GREsau committed Apr 28, 2024
1 parent bbedf13 commit df00e2f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions schemars_derive/src/attr/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ fn wrap_string_validation(v: Vec<TokenStream>) -> Option<TokenStream> {
}

fn str_or_num_to_expr(cx: &Ctxt, meta_item_name: &str, expr: Expr) -> Option<Expr> {
// this odd double-parsing is to make `-10` parsed as an Lit instead of an Expr::Unary
let lit: Lit = match syn::parse2(expr.to_token_stream()) {
Ok(l) => l,
Err(err) => {
Expand Down

0 comments on commit df00e2f

Please sign in to comment.