Coverage Report

Created: 2025-12-31 06:50

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/zmij-1.0.5/src/traits.rs
Line
Count
Source
1
use core::fmt::Display;
2
use core::ops::{Add, BitAnd, BitOr, BitOrAssign, BitXorAssign, Div, Mul, Shl, Shr, Sub};
3
4
pub trait Float: Copy {
5
    const MANTISSA_DIGITS: u32;
6
    const MIN_10_EXP: i32;
7
    const MAX_10_EXP: i32;
8
    const MAX_DIGITS10: u32;
9
}
10
11
impl Float for f32 {
12
    const MANTISSA_DIGITS: u32 = Self::MANTISSA_DIGITS;
13
    const MIN_10_EXP: i32 = Self::MIN_10_EXP;
14
    const MAX_10_EXP: i32 = Self::MAX_10_EXP;
15
    const MAX_DIGITS10: u32 = 9;
16
}
17
18
impl Float for f64 {
19
    const MANTISSA_DIGITS: u32 = Self::MANTISSA_DIGITS;
20
    const MIN_10_EXP: i32 = Self::MIN_10_EXP;
21
    const MAX_10_EXP: i32 = Self::MAX_10_EXP;
22
    const MAX_DIGITS10: u32 = 17;
23
}
24
25
pub trait UInt:
26
    Copy
27
    + From<u8>
28
    + From<bool>
29
    + Add<Output = Self>
30
    + Sub<Output = Self>
31
    + Mul<Output = Self>
32
    + Div<Output = Self>
33
    + BitAnd<Output = Self>
34
    + BitOr<Output = Self>
35
    + Shl<i32, Output = Self>
36
    + Shl<u32, Output = Self>
37
    + Shr<i32, Output = Self>
38
    + Shr<u32, Output = Self>
39
    + BitOrAssign
40
    + BitXorAssign
41
    + PartialOrd
42
    + Into<u64>
43
    + Display
44
{
45
    type Signed: Ord;
46
    fn wrapping_sub(self, other: Self) -> Self;
47
    fn truncate(big: u64) -> Self;
48
    fn enlarge(small: u32) -> Self;
49
    fn to_signed(self) -> Self::Signed;
50
}
51
52
impl UInt for u32 {
53
    type Signed = i32;
54
0
    fn wrapping_sub(self, other: Self) -> Self {
55
0
        self.wrapping_sub(other)
56
0
    }
57
0
    fn truncate(big: u64) -> Self {
58
0
        big as u32
59
0
    }
60
0
    fn enlarge(small: u32) -> Self {
61
0
        small
62
0
    }
63
0
    fn to_signed(self) -> Self::Signed {
64
0
        self as i32
65
0
    }
66
}
67
68
impl UInt for u64 {
69
    type Signed = i64;
70
0
    fn wrapping_sub(self, other: Self) -> Self {
71
0
        self.wrapping_sub(other)
72
0
    }
73
0
    fn truncate(big: u64) -> Self {
74
0
        big
75
0
    }
76
0
    fn enlarge(small: u32) -> Self {
77
0
        u64::from(small)
78
0
    }
79
0
    fn to_signed(self) -> Self::Signed {
80
0
        self as i64
81
0
    }
82
}