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

Remove lots of as casts with modern alternatives: #34

Merged
merged 1 commit into from
Jan 28, 2024

Conversation

alexcrichton
Copy link
Owner

  • a as *mut T => a.cast()
  • a.offset(b as isize) => a.add(b)
  • a.offset(-(b as isize)) => a.sub(b)
  • u32 as usize => usize::try_from(_).unwrap()

In general as has the potential of losing bits so try to avoid it where we can.

* `a as *mut T` => `a.cast()`
* `a.offset(b as isize)` => `a.add(b)`
* `a.offset(-(b as isize))` => `a.sub(b)`
* `u32 as usize` => `usize::try_from(_).unwrap()`

In general `as` has the potential of losing bits so try to avoid it
where we can.
@alexcrichton alexcrichton merged commit 5942886 into main Jan 28, 2024
16 checks passed
@alexcrichton alexcrichton deleted the remove-as-cast branch January 28, 2024 01:54
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.

1 participant