From 72f62781f4b3be01e165bca29f6b277ac7a9fcce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=C3=A4rber?= <01mf02@gmail.com> Date: Tue, 7 Nov 2023 15:00:01 +0100 Subject: [PATCH] Do not panic on empty input. --- src/source.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/source.rs b/src/source.rs index 43982cb..45db40c 100644 --- a/src/source.rs +++ b/src/source.rs @@ -156,7 +156,7 @@ impl> Source { .lines .binary_search_by_key(&offset, |line| line.offset) .unwrap_or_else(|idx| idx.saturating_sub(1)); - let line = self.lines[idx]; + let line = self.line(idx)?; assert!( offset >= line.offset, "offset = {}, line.offset = {}",