Feature gate: #![feature(integer_cast_extras)]
This is a tracking issue for explicit checked, saturating, and strict casts between signed and unsigned primitive integers of equal bit-width.
Public API
For 8, 16, 32, 64, 128, and size integers:
impl uN { pub const fn checked_cast_signed(self) -> Option<iN>; pub const fn saturating_cast_signed(self) -> iN; pub const fn strict_cast_signed(self) -> iN; } impl iN { pub const fn checked_cast_unsigned(self) -> Option<uN>; pub const fn saturating_cast_unsigned(self) -> uN; pub const fn strict_cast_unsigned(self) -> uN; }
Steps / History
- ACP: ACP: Saturating conversions between signed and unsigned integers libs-team#765
- Implementation: core/num: Implement feature
integer_cast_extras#154664 - Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- None yet.