rust2go icon indicating copy to clipboard operation
rust2go copied to clipboard

How to use rust enum type in rust2go

Open leaf-potato opened this issue 1 year ago • 1 comments

#[derive(rust2go::R2G, Debug)]
#[repr(C)]
enum Enum {
    A,
    B,
}

#[derive(rust2go::R2G, Debug)]
struct StructTest {
    a: Enum,
}

When I use enum type in idl, rust2go-cli will report an error:

$ rust2go-cli --src src/service/cf_bypass.rs --dst go/gen.go                                                                                                  [master]
thread 'main' panicked at /Users/leaf-potato/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rust2go-common-0.3.12/src/raw_file.rs:537:26:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

leaf-potato avatar Nov 22 '24 11:11 leaf-potato

I see the existing structures are all lower-level C types, I think you can make an enum by your own.

suikammd avatar Jan 22 '25 15:01 suikammd