Skip to content

Commit

Permalink
tidy up literal prefix handling
Browse files Browse the repository at this point in the history
  • Loading branch information
exrook committed Nov 18, 2023
1 parent e73dc56 commit 5fdf92e
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions autogen/src/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ fn get_decode_method(kind: &str) -> Ident {
return as_ident("id");
}

let mut kind = kind;
if kind.starts_with("Literal") {
kind = &kind["Literal".len()..];
if kind == "Integer" || kind == "Float" {
return as_ident("bit32");
}
match kind.strip_prefix("Literal") {
Some("Integer" | "Float") => as_ident("bit32"),
Some(kind) => as_ident(&kind.to_snake_case()),
None => as_ident(&kind.to_snake_case()),
}
as_ident(&kind.to_snake_case())
}

/// Returns the generated operand decoding errors for binary::Decoder by
Expand Down

0 comments on commit 5fdf92e

Please sign in to comment.