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

Update comment, types #470

Merged
merged 1 commit into from
Aug 20, 2024
Merged

Conversation

adamchalmers
Copy link
Collaborator

@adamchalmers adamchalmers commented Aug 20, 2024

We can use the NonZeroU32 to ensure the Rust code checks if the users passes 0, before passing any u32 to the C++ codebase. You can convert it into u32 using .try_into() or u32::try_from().

@adamchalmers adamchalmers requested a review from mlfarrell August 20, 2024 15:31
@adamchalmers adamchalmers changed the title Update comment Update comment, types Aug 20, 2024
Copy link

codecov bot commented Aug 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 26.84%. Comparing base (c6829d0) to head (de626bd).
Report is 1 commits behind head on mike/lofting-enums.

Additional details and impacted files
@@                  Coverage Diff                   @@
##           mike/lofting-enums     #470      +/-   ##
======================================================
+ Coverage               26.42%   26.84%   +0.41%     
======================================================
  Files                      29       29              
  Lines                    1680     1654      -26     
======================================================
  Hits                      444      444              
+ Misses                   1236     1210      -26     
Flag Coverage Δ
unittests 26.84% <ø> (+0.41%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jtran
Copy link
Contributor

jtran commented Aug 20, 2024

I generally prefer T::from() and T::try_from() over their into counterparts because it's explicit about the type you're converting to (imagine when a code change causes the expected return type to change) and you can go to definition. OTOH, the definition of into() is always the same generic function that calls from() so you can't easily jump to the real conversion code.

@adamchalmers adamchalmers merged commit ca684a2 into mike/lofting-enums Aug 20, 2024
8 checks passed
@adamchalmers adamchalmers deleted the achalmers/code-rev branch August 20, 2024 17:30
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