Closed
Description
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).
# Const Stabilized APIs
- [`<uN>::cast_signed`](https://doc.rust-lang.org/nightly/std/primitive.usize.html#method.cast_signed)
- [`NonZero::<uN>::cast_signed`](https://doc.rust-lang.org/nightly/std/num/struct.NonZero.html#method.cast_signed-5).
- [`<iN>::cast_signed`](https://doc.rust-lang.org/nightly/std/primitive.isize.html#method.cast_signed).
- [`NonZero::<iN>::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