Skip to content

Allow Ptr::offset() to receive any value that can cast to isize#213

Merged
nunoplopes merged 3 commits into
Cpp2Rust:masterfrom
FranciscoTGouveia:offset-try-isize
Jul 1, 2026
Merged

Allow Ptr::offset() to receive any value that can cast to isize#213
nunoplopes merged 3 commits into
Cpp2Rust:masterfrom
FranciscoTGouveia:offset-try-isize

Conversation

@FranciscoTGouveia

Copy link
Copy Markdown
Contributor

The rationale behind this change is to avoid unnecessary casts that may hurt readability, such as: 0_usize as isize.
With this change, we are allowed to omit the cast, as it will be performed inside the offset function.

This also has the advantage of panicking whenever we try to cast a usize larger than isize::MAX.

The rationale behind this change is to avoid unnecessary casts that may
hurt readability, such as: `0_usize as isize`.
With this change, we are allowed to omit the cast, as it will be
performed inside the `offset` function.

This also has the advantage of panicking whenever we try to cast a usize
larger than `isize::MAX`.
@nunoplopes nunoplopes merged commit 8d33dbf into Cpp2Rust:master Jul 1, 2026
5 of 9 checks passed
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 this pull request may close these issues.

3 participants