Skip to content

Commit

Permalink
Merge pull request AleoNet#2500 from ljedrz/refactor/futureproof_lite…
Browse files Browse the repository at this point in the history
…rals

[Chore] Use type_name instead of literals for LiteralType::parse
  • Loading branch information
zosorock authored Nov 19, 2024
2 parents 714e9c3 + c5dd622 commit d432417
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion console/program/src/data_types/literal_type/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub enum LiteralType {

impl LiteralType {
/// Returns the literal type name.
pub fn type_name(&self) -> &str {
pub const fn type_name(&self) -> &str {
match self {
Self::Address => "address",
Self::Boolean => "boolean",
Expand Down
34 changes: 17 additions & 17 deletions console/program/src/data_types/literal_type/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ impl Parser for LiteralType {
fn parse(string: &str) -> ParserResult<Self> {
// Parse the type from the string.
alt((
map(tag("address"), |_| Self::Address),
map(tag("boolean"), |_| Self::Boolean),
map(tag("field"), |_| Self::Field),
map(tag("group"), |_| Self::Group),
map(tag("i8"), |_| Self::I8),
map(tag("i16"), |_| Self::I16),
map(tag("i32"), |_| Self::I32),
map(tag("i64"), |_| Self::I64),
map(tag("i128"), |_| Self::I128),
map(tag("u8"), |_| Self::U8),
map(tag("u16"), |_| Self::U16),
map(tag("u32"), |_| Self::U32),
map(tag("u64"), |_| Self::U64),
map(tag("u128"), |_| Self::U128),
map(tag("scalar"), |_| Self::Scalar),
map(tag("signature"), |_| Self::Signature),
map(tag("string"), |_| Self::String),
map(tag(Self::Address.type_name()), |_| Self::Address),
map(tag(Self::Boolean.type_name()), |_| Self::Boolean),
map(tag(Self::Field.type_name()), |_| Self::Field),
map(tag(Self::Group.type_name()), |_| Self::Group),
map(tag(Self::I8.type_name()), |_| Self::I8),
map(tag(Self::I16.type_name()), |_| Self::I16),
map(tag(Self::I32.type_name()), |_| Self::I32),
map(tag(Self::I64.type_name()), |_| Self::I64),
map(tag(Self::I128.type_name()), |_| Self::I128),
map(tag(Self::U8.type_name()), |_| Self::U8),
map(tag(Self::U16.type_name()), |_| Self::U16),
map(tag(Self::U32.type_name()), |_| Self::U32),
map(tag(Self::U64.type_name()), |_| Self::U64),
map(tag(Self::U128.type_name()), |_| Self::U128),
map(tag(Self::Scalar.type_name()), |_| Self::Scalar),
map(tag(Self::Signature.type_name()), |_| Self::Signature),
map(tag(Self::String.type_name()), |_| Self::String),
))(string)
}
}
Expand Down

0 comments on commit d432417

Please sign in to comment.