recmo/uint

`add`: Replace with `u64::carrying_add` once stable.

github-actions opened this issue · 0 comments

On 2024-04-20 @prestwich wrote in 46fc569 “Merge pull request #366 from DaniPopes/perfington1”:

Replace with u64::carrying_add once stable.

    /// an arithmetic overflow would occur. If an overflow would have occurred
    /// then the wrapped value is returned.
    #[inline]
    #[must_use]
    pub const fn overflowing_add(mut self, rhs: Self) -> (Self, bool) {
        // TODO: Replace with `u64::carrying_add` once stable.
        #[inline]
        const fn u64_carrying_add(lhs: u64, rhs: u64, carry: bool) -> (u64, bool) {
            let (a, b) = lhs.overflowing_add(rhs);
            let (c, d) = a.overflowing_add(carry as u64);
            (c, b || d)

From src/add.rs:59