Skip to content

Commit

Permalink
Add documentation for some of the add/sub/mul intrinsics
Browse files Browse the repository at this point in the history
Part of #34338
  • Loading branch information
wesleywiser committed Nov 9, 2016
1 parent a3f75fb commit a62a67c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1166,12 +1166,21 @@ extern "rust-intrinsic" {
pub fn bswap<T>(x: T) -> T;

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

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

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

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

/// Returns (a + b) mod 2^N, where N is the width of T in bits.
/// The stabilized versions of this intrinsic are available on the integer
/// primitives via the `wrapping_add` method. For example,
/// [`std::u32::wrapping_add`](../../std/primitive.u32.html#method.wrapping_add)
pub fn overflowing_add<T>(a: T, b: T) -> T;
/// Returns (a - b) mod 2^N, where N is the width of T in bits.
/// The stabilized versions of this intrinsic are available on the integer
/// primitives via the `wrapping_sub` method. For example,
/// [`std::u32::wrapping_sub`](../../std/primitive.u32.html#method.wrapping_sub)
pub fn overflowing_sub<T>(a: T, b: T) -> T;
/// Returns (a * b) mod 2^N, where N is the width of T in bits.
/// The stabilized versions of this intrinsic are available on the integer
/// primitives via the `wrapping_mul` method. For example,
/// [`std::u32::wrapping_mul`](../../std/primitive.u32.html#method.wrapping_mul)
pub fn overflowing_mul<T>(a: T, b: T) -> T;

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

0 comments on commit a62a67c

Please sign in to comment.