Skip to content

Replace infallible casts with functions #4583

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Kixunil
Copy link
Collaborator

@Kixunil Kixunil commented May 30, 2025

No description provided.

@github-actions github-actions bot added C-units PRs modifying the units crate C-internals PRs modifying the internals crate C-primitives labels May 30, 2025
@Kixunil Kixunil force-pushed the issue-4581-const-casts branch from 6c3dcef to 36f1cc3 Compare May 31, 2025 13:50
@coveralls
Copy link

Pull Request Test Coverage Report for Build 15364300850

Details

  • 10 of 34 (29.41%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.07%) to 84.563%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internals/src/const_casts.rs 3 27 11.11%
Totals Coverage Status
Change from base Build 15356157383: -0.07%
Covered Lines: 23490
Relevant Lines: 27778

💛 - Coveralls

@yancyribbens
Copy link
Contributor

If I understand your idea, Is it planned to add more like usize_to_u8 and in the function body validate that the usize fits in a a u8? Same idea for going from signed to unsigned and vice versa?

@yancyribbens
Copy link
Contributor

This looks promising though as a way to not accidentally fup a cast in const context.

@Kixunil
Copy link
Collaborator Author

Kixunil commented Jun 1, 2025

No, never the reverse. The point is to prove operations infallible - e.g. for me to not bother you with wrong "this overflows" comments. ;)

@Kixunil
Copy link
Collaborator Author

Kixunil commented Jun 1, 2025

FTR, this PR is draft to not bother people with AI-generated code before I review it. I wanted to give it a shot doing this "dead simple" task but weirdly, it struggles with it. (It did a much more complicated task before.)

@yancyribbens
Copy link
Contributor

for me to not bother you with wrong "this overflows" comments. ;)

I should have commented why "cast ok". This seems about as useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-internals PRs modifying the internals crate C-primitives C-units PRs modifying the units crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy