Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use rust enum type in rust2go #43

Open
leaf-potato opened this issue Nov 22, 2024 · 1 comment
Open

How to use rust enum type in rust2go #43

leaf-potato opened this issue Nov 22, 2024 · 1 comment

Comments

@leaf-potato
Copy link

#[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
@suikammd
Copy link
Collaborator

suikammd commented Jan 22, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants