recmo / uint

Rust Uint crate using const-generics
MIT License
171 stars 40 forks source link

`add`: Replace with `u64::borrowing_sub` once stable. #368

Open github-actions[bot] opened 6 months ago

github-actions[bot] commented 6 months ago

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

Replace with u64::borrowing_sub once stable.

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

From src/add.rs:101