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

Support Direct Conversion Between Subenums Without Converting to Parent #16

Open
itotallyrock opened this issue May 26, 2023 · 0 comments · May be fixed by #22
Open

Support Direct Conversion Between Subenums Without Converting to Parent #16

itotallyrock opened this issue May 26, 2023 · 0 comments · May be fixed by #22

Comments

@itotallyrock
Copy link
Contributor

Right now to convert two different subenum types to each other you must do the following

#[subenum(A, B)]
enum Foo {
    #[subenum(A, B)
    First,
    #[subenum(A, B)
    Second,
    Third,
}
// Current
let a_version: A = A::First;
let b_version: B = B::try_from(Foo::from(a_version))?;
// Desired
let a_version: A = A::First;
let b_version: B = B::try_from(a_version)?;

This extra step of converting to Foo is likely optimized away, but I think its more obvious what is happening with only one conversion.

@Nexelous Nexelous linked a pull request Sep 18, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant