Conversation
mkroening
force-pushed
the
checked-ops
branch
2 times, most recently
from
September 25, 2026 16:23
84e49d5 to
1c7127a
Compare
Note that this does not add a checked version for subtracting two addresses yet.
Note that this changes the panic behavior, since `rhs * S::SIZE` did not panic before without overflow checks. Note that this does not add a checked version for subtracting two pages or frames yet.
mkroening
force-pushed
the
checked-ops
branch
from
September 25, 2026 16:26
1c7127a to
64473e8
Compare
mkroening
force-pushed
the
checked-ops
branch
from
September 25, 2026 16:28
64473e8 to
47d4bd8
Compare
Member
Author
|
CI just made me notice This is really unfortunate, since any crate in the crate graph that enables this feature makes other code in other crates not compile anymore. I don't know if we have any perspective on fixing that and whether we should open an issue for that. |
This was referenced Sep 25, 2026
Open
Member
Author
|
I just noticed #293. That issue proposes traits. This PR adds inherent methods instead, as is done for integers in the standard library. What would you prefer? I'll mark this PR as closing that issue. Please let me know if I should undo that. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds
checked_addandchecked_subconstfunctions corresponding to the currentAddandSubimplementations for:VirtAddrPhysAddrPagePhysFrameMappedPage(not public)MappedPageItem(not public)Note that this changes the panic behavior for
PageandPhysFrame, sincerhs * S::SIZEdid not panic before without overflow checks, such as in the release profile.Also note that this PR does not add a checked version for subtracting two addresses, two pages, or two frames yet, but these would require a different function name. I don't require them personally at the moment. Would you like me to add them anyway? They could be called
checked_offset_from, similar to the corresponding pointer types functions in std. If you prefer, we can also defer this. Adding such methods should not be breaking.This PR is needed for #617 for #611. The approach was discussed in #611 (comment).
This PR is best reviewed commit by commit.
Fixes #293.