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

The std feature is not discoverable (was: FromBitsError doesn't implement Error) #46

Open
drewcassidy opened this issue Jun 30, 2023 · 3 comments

Comments

@drewcassidy
Copy link

enumflags2 uses FromBitsError for the error for TryFrom, but the struct doesnt implement std::error::Error which makes it unwieldy to use, for example with the ? operator or a diagnostics package like Miette

45  | pub struct FromBitsError<T: BitFlag> {
    | ------------------------------------ doesn't satisfy `_: Error`
    |
    = note: the following trait bounds were not satisfied:
            `FromBitsError<DDSPixelFormatFlags>: std::error::Error`
            which is required by `Result<BitFlags<DDSPixelFormatFlags, u32>, FromBitsError<DDSPixelFormatFlags>>: IntoDiagnostic<BitFlags<DDSPixelFormatFlags, u32>, FromBitsError<DDSPixelFormatFlags>>`
@meithecatte
Copy link
Owner

You need to enable the std feature on enumflags2. Though, good point, this is not entirely discoverable, and perhaps the feature should be enabled by default.

@meithecatte meithecatte changed the title FromBitsError doesnt implement Error The std feature is not discoverable (was: FromBitsError doesn't implement Error) Sep 13, 2023
@meithecatte
Copy link
Owner

Marking this as breaking change, as enabling the std feature by default would require action from everyone who's using the library on #![no_std]

@drewcassidy
Copy link
Author

Makes sense. I think it really just needs a more helpful error message but that's more a complaint for the rust compiler team

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

No branches or pull requests

2 participants