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

Refine API-GUIDELINES recommendations #2832

Merged
merged 3 commits into from
Dec 19, 2024

Conversation

bugadani
Copy link
Contributor

Please don't hesitate to voice your opinion if something still doesn't make sense.

@bugadani bugadani added the skip-changelog No changelog modification needed label Dec 18, 2024
- `Clone/Copy` depends on the size and contents of the structure. They should generally be implemented, unless there is a good reason not to.
- The `Default` configuration needs to make sense for a particular driver, and applying the default configuration must not fail.
- Error types: `Debug/Display`, `PartialEq/Eq`, `Clone/Copy`, `Hash`
- Error types: `Debug`, `PartialEq/Eq`, `Clone/Copy`, `Hash`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given we raised the MSRV should we ask for core::error::Error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting that Error requires Display

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should impl Error though. I have a feeling it will help with out documentation related unwrap and ok issues. We should be able to make our doc snippet main fn main() -> Result<(), alloc::Box<dyn core::error::Error>>, and from there we can hopefully ? everything.

If that required Display then I guess we found the reason to impl Display? cc: @jessebraham for your thoughts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that required Display then I guess we found the reason to impl Display?

We found the reason to impl Display in this very particular case yes :D

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For errors yes it probably makes sense, that's generally pretty straight forward to implement. Still don't think it makes sense for other types though, e.g. config structs or drivers.

Copy link
Contributor

@JurajSadel JurajSadel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable to me, thanks!

@bugadani bugadani changed the title Refine C-COMMON-TRAITS recommendations Refine API-GUIDELINES recommendations Dec 18, 2024
@jessebraham jessebraham added this pull request to the merge queue Dec 19, 2024
Merged via the queue into esp-rs:main with commit b8f15f0 Dec 19, 2024
28 checks passed
@bugadani bugadani deleted the refine-guideline branch December 19, 2024 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog No changelog modification needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants