Skip to content

implement ZeroableOption for NonZero* types#110

Merged
BennoLossin merged 1 commit intoRust-for-Linux:mainfrom
Hamdan-Khan:main
Mar 8, 2026
Merged

implement ZeroableOption for NonZero* types#110
BennoLossin merged 1 commit intoRust-for-Linux:mainfrom
Hamdan-Khan:main

Conversation

@Hamdan-Khan
Copy link
Contributor

add a macro for implementing ZeroableOption for NonZero* integer types instead of using Option<NonZero*> inside zeroable macro

issue: #95

Copy link
Member

@BennoLossin BennoLossin left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the PR!

Please use the kernel's commit message style. So give a motivation in addition to explaining what the change is.

We also don't use the issue: tag. Instead use Link:.

Please also mention this change in the changelog.

Copy link
Member

@BennoLossin BennoLossin left a comment

Choose a reason for hiding this comment

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

The code itself looks good. One suggestion for the changelog inline.

Lastly, we should offer some motivation for the change in the commit message. The idea is that Option<NonZero*> automatically implements Zeroable through the blanket impl that comes from implementing ZeroableOption for NonZero*, better encoding the situation.

Copy link
Member

@BennoLossin BennoLossin left a comment

Choose a reason for hiding this comment

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

Changes look good now, thanks!

Can you rebase on top of main? Then we can re-run the CI tests.

@Hamdan-Khan
Copy link
Contributor Author

Can you rebase on top of main? Then we can re-run the CI tests.

Sure!

add a macro for implementing `ZeroableOption` for `NonZero*` types.

`Option<NonZero*>` now automatically implements `Zeroable` trait  by
implementing `ZeroableOption` for `NonZero*` types, which serves as a
blanket impl.

Closes: Rust-for-Linux#95
Signed-off-by: Hamdan-Khan <hamdankhan212@gmail.com>
Signed-off-by: Benno Lossin <lossin@kernel.org>
@BennoLossin BennoLossin merged commit d316316 into Rust-for-Linux:main Mar 8, 2026
26 checks passed
@BennoLossin
Copy link
Member

Thanks!

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants