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

fix: clean up #[allow(clippy::from_over_into)] #131

Merged
merged 1 commit into from
Nov 4, 2024

Conversation

metatoaster
Copy link
Contributor

Using the From trait is more idiomatic, and not to mention it allows the conversion to be invoked directly via the target type's from:

let arena = &mut Arena::new();
let a = arena.new_node(1);
dbg!(usize::from(a));
dbg!(NonZeroUsize::from(a));
dbg!(usize::from(a) as u64)

Rather than going through a much more verbose syntax as required currently, especially when a u64 is desired.

dbg!(<NodeId as Into<usize>>::into(a));
dbg!(<NodeId as Into<usize>>::into(a) as u64);

@saschagrunert
Copy link
Owner

@metatoaster thank you for the PR, do you mind a rebase to fixup the CI?

- This enables the more idiomatic conversion `usize::from(node_id)`.
- Added conversion traits tests.
Copy link

codecov bot commented Nov 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.8%. Comparing base (c912895) to head (57ecdb5).
Report is 20 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##            main    #131      +/-   ##
========================================
+ Coverage   54.5%   87.8%   +33.2%     
========================================
  Files          9       9              
  Lines        559    1186     +627     
  Branches     188       0     -188     
========================================
+ Hits         305    1042     +737     
- Misses       135     144       +9     
+ Partials     119       0     -119     

@metatoaster
Copy link
Contributor Author

metatoaster commented Nov 4, 2024

Threw in conversion tests at the last minute for coverage completeness sake. Thanks for looking into these changes.

@saschagrunert saschagrunert merged commit 4fc870e into saschagrunert:main Nov 4, 2024
8 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.

2 participants