Add custom error message for rope cursor slice precondition

This commit is contained in:
Max Brunsfeld 2021-06-02 17:47:25 -07:00
parent e021154852
commit 68994248ee

View file

@ -213,7 +213,12 @@ impl<'a> Cursor<'a> {
}
pub fn slice(&mut self, end_offset: usize) -> Rope {
debug_assert!(end_offset >= self.offset);
debug_assert!(
end_offset >= self.offset,
"cannot slice backwards from {} to {}",
self.offset,
end_offset
);
let mut slice = Rope::new();
if let Some(start_chunk) = self.chunks.item() {