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

Tracking issue for release notes of #125882: Tracking Issue for integer_sign_cast #136560

Open
2 of 3 tasks
rustbot opened this issue Feb 4, 2025 · 0 comments
Open
2 of 3 tasks
Labels
I-release-nominated Nominated for the release team. relnotes Marks issues that should be documented in the release notes of the next release. relnotes-tracking-issue Marks issues tracking what text to put in release notes. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Milestone

Comments

@rustbot
Copy link
Collaborator

rustbot commented Feb 4, 2025

This issue tracks the release notes text for #125882.

Steps

  • Proposed text is drafted by PR author (or team) making the noteworthy change.
  • Issue is nominated for release team review of clarity for wider audience.
  • Release team includes text in release notes/blog posts.

Release notes text

The responsible team for the underlying change should edit this section to replace the automatically generated link with a succinct description of what changed, drawing upon text proposed by the author (either in discussion or through direct editing).

# Stabilized APIs
- `cast_signed` for unsigned integer types: [`u8::cast_signed`](https://doc.rust-lang.org/nightly/std/primitive.u8.html#method.cast_signed), [`u16::cast_signed`](https://doc.rust-lang.org/nightly/std/primitive.u16.html#method.cast_signed), [`u32::cast_signed`](https://doc.rust-lang.org/nightly/std/primitive.u32.html#method.cast_signed), [`u64::cast_signed`](https://doc.rust-lang.org/nightly/std/primitive.u64.html#method.cast_signed), [`u128::cast_signed`](https://doc.rust-lang.org/nightly/std/primitive.u128.html#method.cast_signed), [`usize::cast_signed`](https://doc.rust-lang.org/nightly/std/primitive.usize.html#method.cast_signed).
- `cast_signed` for unsigned `NonZero` integer types: [`NonZero::<u8>::cast_signed`](https://doc.rust-lang.org/nightly/std/num/struct.NonZero.html#method.cast_signed), [`NonZero::<u16>::cast_signed`](https://doc.rust-lang.org/nightly/std/num/struct.NonZero.html#method.cast_signed-1), [`NonZero::<u32>::cast_signed`](https://doc.rust-lang.org/nightly/std/num/struct.NonZero.html#method.cast_signed-2), [`NonZero::<u64>::cast_signed`](https://doc.rust-lang.org/nightly/std/num/struct.NonZero.html#method.cast_signed-3), [`NonZero::<u128>::cast_signed`](https://doc.rust-lang.org/nightly/std/num/struct.NonZero.html#method.cast_signed-4), [`NonZero::<usize>::cast_signed`](https://doc.rust-lang.org/nightly/std/num/struct.NonZero.html#method.cast_signed-5).
- `cast_unsigned` for signed integer types: [`i8::cast_signed`](https://doc.rust-lang.org/nightly/std/primitive.i8.html#method.cast_signed), [`i16::cast_signed`](https://doc.rust-lang.org/nightly/std/primitive.i16.html#method.cast_signed), [`i32::cast_signed`](https://doc.rust-lang.org/nightly/std/primitive.i32.html#method.cast_signed), [`i64::cast_signed`](https://doc.rust-lang.org/nightly/std/primitive.i64.html#method.cast_signed), [`i128::cast_signed`](https://doc.rust-lang.org/nightly/std/primitive.i128.html#method.cast_signed), [`isize::cast_signed`](https://doc.rust-lang.org/nightly/std/primitive.isize.html#method.cast_signed).
- `cast_unsigned` for signed `NonZero` integer types: [`NonZero::<i8>::cast_unsigned`](https://doc.rust-lang.org/nightly/std/num/struct.NonZero.html#method.cast_unsigned), [`NonZero::<i16>::cast_unsigned`](https://doc.rust-lang.org/nightly/std/num/struct.NonZero.html#method.cast_unsigned-1), [`NonZero::<i32>::cast_unsigned`](https://doc.rust-lang.org/nightly/std/num/struct.NonZero.html#method.cast_unsigned-2), [`NonZero::<i64>::cast_unsigned`](https://doc.rust-lang.org/nightly/std/num/struct.NonZero.html#method.cast_unsigned-3), [`NonZero::<i128>::cast_unsigned`](https://doc.rust-lang.org/nightly/std/num/struct.NonZero.html#method.cast_unsigned-4), [`NonZero::<isize>::cast_unsigned`](https://doc.rust-lang.org/nightly/std/num/struct.NonZero.html#method.cast_unsigned-5).

Tip

Use the previous releases categories to help choose which one(s) to use.
The category will be de-duplicated with all the other ones by the release team.

More than one section can be included if needed.

Release blog section

If the change is notable enough for inclusion in the blog post, the responsible team should add content to this section.
Otherwise leave it empty.

When casting from a signed integer type to an unsigned integer type or vice versa, you can now use the `cast_unsigned` or `cast_signed` methods, rather than using `as`. These methods are safer, as they will only convert to the matching type, while `as` performs a much wider range of conversions without complaint.

```rust
let x = -1i8;
let y = x.cast_unsigned();
assert_eq!(y, 255u8);
```

cc @Rua -- origin issue/PR authors and assignees for starting to draft text

@rustbot rustbot added relnotes Marks issues that should be documented in the release notes of the next release. relnotes-tracking-issue Marks issues tracking what text to put in release notes. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 4, 2025
@joshtriplett joshtriplett added I-release-nominated Nominated for the release team. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 10, 2025
@cuviper cuviper added this to the 1.87.0 milestone Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-release-nominated Nominated for the release team. relnotes Marks issues that should be documented in the release notes of the next release. relnotes-tracking-issue Marks issues tracking what text to put in release notes. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants