File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,14 @@ impl<const N: usize> MeasurementLog<N> {
156
156
self . index as usize == N
157
157
}
158
158
159
+ pub fn is_empty ( & self ) -> bool {
160
+ self . index == 0
161
+ }
162
+
163
+ pub fn len ( & self ) -> u32 {
164
+ self . index
165
+ }
166
+
159
167
pub fn push ( & mut self , measurement : Measurement ) -> bool {
160
168
if !self . is_full ( ) {
161
169
self . measurements [ self . index as usize ] = measurement;
@@ -167,6 +175,13 @@ impl<const N: usize> MeasurementLog<N> {
167
175
}
168
176
}
169
177
178
+ impl < const N : usize > core:: ops:: Index < u32 > for MeasurementLog < N > {
179
+ type Output = Measurement ;
180
+ fn index ( & self , i : u32 ) -> & Self :: Output {
181
+ & self . measurements [ i as usize ]
182
+ }
183
+ }
184
+
170
185
impl < const N : usize > Default for MeasurementLog < N > {
171
186
fn default ( ) -> Self {
172
187
Self {
You can’t perform that action at this time.
0 commit comments