We seem to run into panics in related code, so better assert early Release Notes: - N/A *or* Added/Fixed/Improved ...
Unified · Split
| @@ -673,6 +673,12 @@ impl<'a> Chunks<'a> { · 672 unmodified lines | ||
| 673 | 673 | chunks.seek(&range.start, Bias::Right); |
| 674 | 674 | range.start |
| 675 | 675 | }; |
| 676 | + let chunk_offset = offset - chunks.start(); | |
| 677 | + if let Some(chunk) = chunks.item() | |
| 678 | + && !chunk.text.is_char_boundary(chunk_offset) | |
| 679 | + { | |
| 680 | + panic!("byte index {} is not a char boundary", offset); | |
| 681 | + } | |
| 676 | 682 | Self { |
| 677 | 683 | chunks, |
| 678 | 684 | range, |