Add Utility Trait to Convert from u32 to usize#310
Merged
florianhartung merged 3 commits intomainfrom Feb 18, 2026
Merged
Conversation
c60d87a to
918e333
Compare
918e333 to
67c6589
Compare
Contributor
|
67c6589 to
c660e7a
Compare
90511cb to
3fb67f2
Compare
Signed-off-by: Florian Hartung <florian.hartung@dlr.de>
Signed-off-by: Florian Hartung <florian.hartung@dlr.de>
Signed-off-by: Florian Hartung <florian.hartung@dlr.de>
3fb67f2 to
37c0b66
Compare
dadada
approved these changes
Feb 18, 2026
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.
Because Wasm uses
u32s for indexing and Rust usesusizes, we have to convert a lot ofu32s tousizes.In Rust it is generally not recommended to use the
askeyword to cast between numerical types, because they might result in unexpected errors, imprecision or other unexpected sign extension behaviors. Normally, theFrom/Intotraits should be used instead. However Rust does not provide aFrom<u32> for usizeimplementation.Therefore, this PR adds a new utility trait to convert from a
u32to ausize.While we might want to support targets with a 16 bit pointer width in the future, this is a small and easy solution for now.
Checks
nix fmtnix flake check '.?submodules=1'cargo fmtcargo testcargo checkcargo buildcargo doc