1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/// Implements checked arithmetic operations for the specified types.
///
/// This macro generates implementations of the `CheckedAdd`, `CheckedSub`,
/// `CheckedMul`, `CheckedDiv`, and `CheckedRem` traits for the given types.
/// These traits provide methods for performing arithmetic operations that
/// return an `Option` containing the result, instead of panicking on overflow
/// or division by zero.
///
/// # Examples
///
// `impl_checked_arithmetic!(u8 u16 u32 u64 i8 i16 i32 i64);`
///
/// In this example, the `impl_checked_arithmetic` macro is used to generate
/// implementations of the `CheckedAdd`, `CheckedSub`, `CheckedMul`,
/// `CheckedDiv`, and `CheckedRem` traits for the types `u8`, `u16`, `u32`,
/// `u64`, `i8`, `i16`, `i32`, and `i64`.
///
/// The generated implementations provide methods like `checked_add`, `checked_sub`,
/// `checked_mul`, `checked_div`, and `checked_rem` that can be used to perform
/// arithmetic operations that return an `Option` containing the result.
///
/// # Safety
///
/// The generated implementations rely on the underlying arithmetic operations
/// provided by the types. It is important to ensure that the types being used
/// implement the necessary arithmetic operations correctly and handle overflow
/// and division by zero appropriately.
///
/// # Panics
///
/// The generated implementations do not panic on overflow or division by zero.
/// Instead, they return `None` to indicate that the operation could not be
/// performed without overflowing or dividing by zero.