Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a795502

Browse files
committedApr 6, 2025··
Simplify implementation of ordered_get.
1 parent 2f0008b commit a795502

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed
 

‎src/histbuf.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -527,16 +527,7 @@ impl<T, S: HistBufStorage<T> + ?Sized> HistoryBufferInner<T, S> {
527527
/// assert_eq!(buffer.ordered_get(6), None);
528528
/// ```
529529
pub fn ordered_get(&self, idx: usize) -> Option<&T> {
530-
if self.len() <= idx {
531-
None
532-
} else {
533-
let (front, back) = self.as_slices();
534-
if idx < front.len() {
535-
Some(&front[idx])
536-
} else {
537-
Some(&back[idx - front.len()])
538-
}
539-
}
530+
self.oldest_ordered().nth(idx)
540531
}
541532

542533
/// Returns double ended iterator for iterating over the buffer from

0 commit comments

Comments
 (0)
Please sign in to comment.