Skip to content

Commit a62a67c

Browse files
committed
Add documentation for some of the add/sub/mul intrinsics
Part of #34338
1 parent a3f75fb commit a62a67c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/libcore/intrinsics.rs

+18
Original file line numberDiff line numberDiff line change
@@ -1166,12 +1166,21 @@ extern "rust-intrinsic" {
11661166
pub fn bswap<T>(x: T) -> T;
11671167

11681168
/// Performs checked integer addition.
1169+
/// The stabilized versions of this intrinsic are available on the integer
1170+
/// primitives via the `overflowing_add` method. For example,
1171+
/// [`std::u32::overflowing_add`](../../std/primitive.u32.html#method.overflowing_add)
11691172
pub fn add_with_overflow<T>(x: T, y: T) -> (T, bool);
11701173

11711174
/// Performs checked integer subtraction
1175+
/// The stabilized versions of this intrinsic are available on the integer
1176+
/// primitives via the `overflowing_sub` method. For example,
1177+
/// [`std::u32::overflowing_sub`](../../std/primitive.u32.html#method.overflowing_sub)
11721178
pub fn sub_with_overflow<T>(x: T, y: T) -> (T, bool);
11731179

11741180
/// Performs checked integer multiplication
1181+
/// The stabilized versions of this intrinsic are available on the integer
1182+
/// primitives via the `overflowing_mul` method. For example,
1183+
/// [`std::u32::overflowing_mul`](../../std/primitive.u32.html#method.overflowing_mul)
11751184
pub fn mul_with_overflow<T>(x: T, y: T) -> (T, bool);
11761185

11771186
/// Performs an unchecked division, resulting in undefined behavior
@@ -1182,10 +1191,19 @@ extern "rust-intrinsic" {
11821191
pub fn unchecked_rem<T>(x: T, y: T) -> T;
11831192

11841193
/// Returns (a + b) mod 2^N, where N is the width of T in bits.
1194+
/// The stabilized versions of this intrinsic are available on the integer
1195+
/// primitives via the `wrapping_add` method. For example,
1196+
/// [`std::u32::wrapping_add`](../../std/primitive.u32.html#method.wrapping_add)
11851197
pub fn overflowing_add<T>(a: T, b: T) -> T;
11861198
/// Returns (a - b) mod 2^N, where N is the width of T in bits.
1199+
/// The stabilized versions of this intrinsic are available on the integer
1200+
/// primitives via the `wrapping_sub` method. For example,
1201+
/// [`std::u32::wrapping_sub`](../../std/primitive.u32.html#method.wrapping_sub)
11871202
pub fn overflowing_sub<T>(a: T, b: T) -> T;
11881203
/// Returns (a * b) mod 2^N, where N is the width of T in bits.
1204+
/// The stabilized versions of this intrinsic are available on the integer
1205+
/// primitives via the `wrapping_mul` method. For example,
1206+
/// [`std::u32::wrapping_mul`](../../std/primitive.u32.html#method.wrapping_mul)
11891207
pub fn overflowing_mul<T>(a: T, b: T) -> T;
11901208

11911209
/// Returns the value of the discriminant for the variant in 'v',

0 commit comments

Comments
 (0)