pub fn fetch_sub(&self, number_kind: &NumberKind, val: &Number) {
        match number_kind {
            NumberKind::I64 => {
                let mut old = self.0.load(Ordering::Acquire);
                loop {
                    let new = (old as i64).wrapping_sub(val.0 as i64) as u64;
                    match self.0.compare_exchange_weak(
                        old,
                        new,
                        Ordering::AcqRel,
                        Ordering::Relaxed,
                    ) {
                        Ok(_) => break,
                        Err(x) => old = x,
                    };
                }
            }
            NumberKind::F64 => {
                let mut old = self.0.load(Ordering::Acquire);
                loop {
                    let new = u64_to_f64(old) - u64_to_f64(val.0);
                    match self.0.compare_exchange_weak(
                        old,
                        f64_to_u64(new),
                        Ordering::AcqRel,
                        Ordering::Acquire,
                    ) {
                        Ok(_) => break,
                        Err(x) => old = x,
                    };
                }
            }
            NumberKind::U64 => {
                self.0.fetch_sub(val.0, Ordering::AcqRel);
            }
        }
    }
/// Subtracts from the current number. Both numbers must be of the same kind.
///
/// This operation wraps around on overflow for `u64` and `i64` types and is
/// `-inf` for `f64`.
Subtracts from the current number. Both numbers must be of the same kind.
Subtracts from the current number . Both numbers must be of the same kind .
pub fn fetch_sub(&self, number_kind: &NumberKind, val: &Number) {
        match number_kind {
            NumberKind::I64 => {
                let mut old = self.0.load(Ordering::Acquire);
                loop {
                    let new = (old as i64).wrapping_sub(val.0 as i64) as u64;
                    match self.0.compare_exchange_weak(
                        old,
                        new,
                        Ordering::AcqRel,
                        Ordering::Relaxed,
                    ) {
                        Ok(_) => break,
                        Err(x) => old = x,
                    };
                }
            }
            NumberKind::F64 => {
                let mut old = self.0.load(Ordering::Acquire);
                loop {
                    let new = u64_to_f64(old) - u64_to_f64(val.0);
                    match self.0.compare_exchange_weak(
                        old,
                        f64_to_u64(new),
                        Ordering::AcqRel,
                        Ordering::Acquire,
                    ) {
                        Ok(_) => break,
                        Err(x) => old = x,
                    };
                }
            }
            NumberKind::U64 => {
                self.0.fetch_sub(val.0, Ordering::AcqRel);
            }
        }
    }
pub fn fetch_sub ( & self , number_kind : & NumberKind , val : & Number ) { match number_kind { NumberKind :: I64 => { let mut old = self . 0 . load ( Ordering :: Acquire ) ; loop { let new = ( old as i64 ) . wrapping_sub ( val . 0 as i64 ) as u64 ; match self . 0 . compare_exchange_weak ( old , new , Ordering :: AcqRel , Ordering :: Relaxed , ) { Ok ( _ ) => break , Err ( x ) => old = x , } ; } } NumberKind :: F64 => { let mut old = self . 0 . load ( Ordering :: Acquire ) ; loop { let new = u64_to_f64 ( old ) - u64_to_f64 ( val . 0 ) ; match self . 0 . compare_exchange_weak ( old , f64_to_u64 ( new ) , Ordering :: AcqRel , Ordering :: Acquire , ) { Ok ( _ ) => break , Err ( x ) => old = x , } ; } } NumberKind :: U64 => { self . 0 . fetch_sub ( val . 0 , Ordering :: AcqRel ) ; } } }
Subtracts from the current number.
Subtracts from the current number .
&self
number_kind
&NumberKind
val
&Number
&self
number_kind
&NumberKind
val
&Number