Skip to content

[rust] Cannot set the null value of enums, but can in c++, java, go #1116

Description

@espindola

Given the included xml and reproducer script, one gets

java
out/java/repro/FooBarViaAttr.java:    NULL_VAL((short)254);
out/java/repro/FooBarViaType.java:    NULL_VAL((short)254);

cpp
out/cpp/repro/FooBarViaAttr.h:        NULL_VALUE = static_cast<std::uint8_t>(254)
out/cpp/repro/FooBarViaType.h:        NULL_VALUE = static_cast<std::uint8_t>(254)

go
out/golang/repro/FooBarViaAttr.go:var FooBarViaAttr = FooBarViaAttrValues{0, 1, 254}
out/golang/repro/FooBarViaType.go:var FooBarViaType = FooBarViaTypeValues{0, 1, 254}

rust
out/rust/repro/src/foo_bar_via_attr.rs:    NullVal = 0xff_u8, 
out/rust/repro/src/foo_bar_via_type.rs:    NullVal = 0xff_u8, 

So rust is the odd one out in not changing the encoding of the null value.

enum-null-value.xml

run.sh

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions