Skip to content

Conversation

@link2xt
Copy link
Collaborator

@link2xt link2xt commented Dec 6, 2025

Follow-up to #7572

@link2xt link2xt force-pushed the link2xt/less-usize branch from 5211cd2 to a2d57d4 Compare December 6, 2025 15:33
/// and <https://users.rust-lang.org/t/cant-convert-usize-to-u64/6243>
/// and <https://github.com/rust-lang/rust/issues/106050>.
pub(crate) fn usize_to_u64(v: usize) -> u64 {
u64::try_from(v).unwrap_or(u64::MAX)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just unwrap()? Panics that can't really happen should be fine

Copy link
Collaborator Author

@link2xt link2xt Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with adding unwrap() in places that cannot happen is that once the app without debug info crashes on a phone for some user, you now need to look at all the places which may panic. E.g. you add 100 unwraps(), get one wrong and it actually panics, and then you need to review 100 places. This also includes all the dependencies, so if some dependency crashes with .unwrap(), if we don't have .unwrap() in our code we can immediately know that this is not caused by our own code.

@link2xt link2xt merged commit 0defa11 into main Dec 7, 2025
30 checks passed
@link2xt link2xt deleted the link2xt/less-usize branch December 7, 2025 13:23
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.

4 participants