## Coverage Report

#### Created: 2025-08-26 07:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)

    /Users/andrewlamb/Software/arrow-rs/arrow-buffer/src/arith.rs

    Line
    Count
    Source
    1
    // Licensed to the Apache Software Foundation (ASF) under one
    2
    // or more contributor license agreements.  See the NOTICE file
    3
    // distributed with this work for additional information
    4
    // regarding copyright ownership.  The ASF licenses this file
    5
    // to you under the Apache License, Version 2.0 (the
    6
    // "License"); you may not use this file except in compliance
    7
    // with the License.  You may obtain a copy of the License at
    8
    //
    9
    //   http://www.apache.org/licenses/LICENSE-2.0
    10
    //
    11
    // Unless required by applicable law or agreed to in writing,
    12
    // software distributed under the License is distributed on an
    13
    // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    14
    // KIND, either express or implied.  See the License for the
    15
    // specific language governing permissions and limitations
    16
    // under the License.
    17
    18
    /// Derives `std::ops::$t` for `$ty` calling `$wrapping` or `$checked` variants
    19
    /// based on if debug_assertions enabled
    20
    macro_rules! derive_arith {
    21
        ($ty:ty, $t:ident, $t_assign:ident, $op:ident, $op_assign:ident, $wrapping:ident, $checked:ident) => {
    22
            impl std::ops::$t for $ty {
    23
                type Output = $ty;
    24
    25
                #[cfg(debug_assertions)]
    26
    0
                fn $op(self, rhs: Self) -> Self::Output {
    27
    0
                    self.$checked(rhs)
    28
    0
                        .expect(concat!(stringify!($ty), " overflow"))
    29
    0
                }
    30
    31
                #[cfg(not(debug_assertions))]
    32
                fn $op(self, rhs: Self) -> Self::Output {
    33
                    self.$wrapping(rhs)
    34
                }
    35
            }
    36
    37
            impl std::ops::$t_assign for $ty {
    38
                #[cfg(debug_assertions)]
    39
    0
                fn $op_assign(&mut self, rhs: Self) {
    40
    0
                    *self = self
    41
    0
                        .$checked(rhs)
    42
    0
                        .expect(concat!(stringify!($ty), " overflow"));
    43
    0
                }
    44
    45
                #[cfg(not(debug_assertions))]
    46
                fn $op_assign(&mut self, rhs: Self) {
    47
                    *self = self.$wrapping(rhs);
    48
                }
    49
            }
    50
    51
            impl<'a> std::ops::$t<$ty> for &'a $ty {
    52
                type Output = $ty;
    53
    54
    0
                fn $op(self, rhs: $ty) -> Self::Output {
    55
    0
                    (*self).$op(rhs)
    56
    0
                }
    57
            }
    58
    59
            impl<'a> std::ops::$t<&'a $ty> for $ty {
    60
                type Output = $ty;
    61
    62
    0
                fn $op(self, rhs: &'a $ty) -> Self::Output {
    63
    0
                    self.$op(*rhs)
    64
    0
                }
    65
            }
    66
    67
            impl<'a, 'b> std::ops::$t<&'b $ty> for &'a $ty {
    68
                type Output = $ty;
    69
    70
    0
                fn $op(self, rhs: &'b $ty) -> Self::Output {
    71
    0
                    (*self).$op(*rhs)
    72
    0
                }
    73
            }
    74
        };
    75
    }
    76
    77
    pub(crate) use derive_arith;