Coverage Report

Created: 2025-07-01 07:43

/rust/registry/src/index.crates.io-6f17d22bba15001f/simd-adler32-0.3.7/src/hash.rs
Line
Count
Source (jump to first uncovered line)
1
use crate::{Adler32, Adler32Hash};
2
3
impl Adler32Hash for &[u8] {
4
0
  fn hash(&self) -> u32 {
5
0
    let mut hash = Adler32::new();
6
0
7
0
    hash.write(self);
8
0
    hash.finish()
9
0
  }
10
}
11
12
impl Adler32Hash for &str {
13
0
  fn hash(&self) -> u32 {
14
0
    let mut hash = Adler32::new();
15
0
16
0
    hash.write(self.as_bytes());
17
0
    hash.finish()
18
0
  }
19
}
20
21
#[cfg(feature = "const-generics")]
22
impl<const SIZE: usize> Adler32Hash for [u8; SIZE] {
23
0
  fn hash(&self) -> u32 {
24
0
    let mut hash = Adler32::new();
25
0
26
0
    hash.write(self);
27
0
    hash.finish()
28
0
  }
29
}
30
31
macro_rules! array_impl {
32
  ($s:expr, $($size:expr),+) => {
33
    array_impl!($s);
34
    $(array_impl!{$size})*
35
  };
36
  ($size:expr) => {
37
    #[cfg(not(feature = "const-generics"))]
38
    impl Adler32Hash for [u8; $size] {
39
      fn hash(&self) -> u32 {
40
        let mut hash = Adler32::new();
41
42
        hash.write(self);
43
        hash.finish()
44
      }
45
    }
46
  };
47
}
48
49
array_impl!(
50
  0,
51
  1,
52
  2,
53
  3,
54
  4,
55
  5,
56
  6,
57
  7,
58
  8,
59
  9,
60
  10,
61
  11,
62
  12,
63
  13,
64
  14,
65
  15,
66
  16,
67
  17,
68
  18,
69
  19,
70
  20,
71
  21,
72
  22,
73
  23,
74
  24,
75
  25,
76
  26,
77
  27,
78
  28,
79
  29,
80
  30,
81
  31,
82
  32,
83
  33,
84
  34,
85
  35,
86
  36,
87
  37,
88
  38,
89
  39,
90
  40,
91
  41,
92
  42,
93
  43,
94
  44,
95
  45,
96
  46,
97
  47,
98
  48,
99
  49,
100
  50,
101
  51,
102
  52,
103
  53,
104
  54,
105
  55,
106
  56,
107
  57,
108
  58,
109
  59,
110
  60,
111
  61,
112
  62,
113
  63,
114
  64,
115
  65,
116
  66,
117
  67,
118
  68,
119
  69,
120
  70,
121
  71,
122
  72,
123
  73,
124
  74,
125
  75,
126
  76,
127
  77,
128
  78,
129
  79,
130
  80,
131
  81,
132
  82,
133
  83,
134
  84,
135
  85,
136
  86,
137
  87,
138
  88,
139
  89,
140
  90,
141
  91,
142
  92,
143
  93,
144
  94,
145
  95,
146
  96,
147
  97,
148
  98,
149
  99,
150
  100,
151
  1024,
152
  1024 * 1024,
153
  1024 * 1024 * 1024,
154
  2048,
155
  4096
156
);