Commit 2315b5f
authored
feat(log): add first() and last() methods (#402)
### Motivation
- Provide convenient accessors for the first and last log entries.
### Solution
- Implemented first(&self) -> Option<T> returning self.get(0).
- Implemented last(&self) -> Option<T> returning the last entry or None
when empty.
- Both are inlined and O(1) complexity.
### Details
- first/last preserve existing retrieval semantics and types.
- last handles empty logs safely by early None.
### Meta
updated tests accordingly1 parent c567ed2 commit 2315b5f
2 files changed
+39
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
183 | 203 | | |
184 | 204 | | |
185 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
224 | 243 | | |
225 | 244 | | |
226 | 245 | | |
| |||
0 commit comments