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

Replace NonZero* type usage with NonZero<T> variant #14974

Closed
ItsDoot opened this issue Aug 29, 2024 · 0 comments · Fixed by #14978
Closed

Replace NonZero* type usage with NonZero<T> variant #14974

ItsDoot opened this issue Aug 29, 2024 · 0 comments · Fixed by #14978
Labels
A-Cross-Cutting Impacts the entire engine C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Domain-Agnostic Can be tackled by anyone with generic programming or Rust skills D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!

Comments

@ItsDoot
Copy link
Contributor

ItsDoot commented Aug 29, 2024

What problem does this solve or what need does it fill?

Newly introduced in Rust 1.79.0, NonZero<T> is a generic variant of the NonZero* types. Unfortunately, this doesn't allow usage as a wrapper for custom types, as ZeroablePrimitive is currently unstable.

Some usages might be blocked on rust-lang/rust#84186, but that is to be discovered.

What solution would you like?

Replace all usages of NonZero* with NonZero<T>, such as NonZeroU32 with NonZero<u32>.

What alternative(s) have you considered?

Continue as-is.

@ItsDoot ItsDoot added C-Usability A targeted quality-of-life change that makes Bevy easier to use A-Cross-Cutting Impacts the entire engine D-Straightforward Simple bug fixes and API improvements, docs, test and examples D-Domain-Agnostic Can be tackled by anyone with generic programming or Rust skills labels Aug 29, 2024
@alice-i-cecile alice-i-cecile added the S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! label Aug 29, 2024
github-merge-queue bot pushed a commit that referenced this issue Aug 30, 2024
# Objective

- Fixes #14974

## Solution

- Replace all* instances of `NonZero*` with `NonZero<*>`

## Testing

- CI passed locally.

---

## Notes

Within the `bevy_reflect` implementations for `std` types,
`impl_reflect_value!()` will continue to use the type aliases instead,
as it inappropriately parses the concrete type parameter as a generic
argument. If the `ZeroablePrimitive` trait was stable, or the macro
could be modified to accept a finite list of types, then we could fully
migrate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Cross-Cutting Impacts the entire engine C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Domain-Agnostic Can be tackled by anyone with generic programming or Rust skills D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants