Is there a way to initialize conditional field with same name?

Just like:

struct {
#[cfg(condition)]
a: typa,
#[cfg(not(condition))]
a: typa2,
}

Do you mean declare? Yes.

If you mean something else, it's not clear what you mean.

I have got the way, we can try cfg proc macro to static dispatch to two new functions.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.