Skip to content

[Bug] Rust generation: Make key ordered when creating a Map. #59

@MathieuDutSik

Description

@MathieuDutSik

🐛 Bug

When creating a Map, it is necessary to have the keys that are ordered.
However, the generated code does not have the ordering trait.

To reproduce

The following example gives code that does not compile.

Epoch:
  NEWTYPESTRUCT: U32
ChainInfo:
  STRUCT:
    - onemap:
        MAP:
          KEY:
            TYPENAME: Epoch
          VALUE:
            TYPENAME: Epoch

The generated rust code will not compile due to the lack of Ord and Eq trait assignments. I have not tested but the code should also fail for C++ since C++ requires the operator< to be implemented. Other languages likely have similar issues.

Expected Behavior

There are several ways to address this issue:

  • One is to implement the ordering functions whenever they are needed.
  • One is to liberally implement the types.
  • Identify when a type implements a map over a type containing some floating number and indicate it as invalid.

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions