Add verify macros & use in one location for point conversion
This commit is contained in:
parent
3a1cd6ed3a
commit
5965113fc8
6 changed files with 61 additions and 5 deletions
|
@ -12,7 +12,7 @@ smallvec = { version = "1.6", features = ["union"] }
|
|||
sum_tree = { path = "../sum_tree" }
|
||||
arrayvec = "0.7.1"
|
||||
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
||||
|
||||
verify = { path = "../verify" }
|
||||
|
||||
[dev-dependencies]
|
||||
rand = "0.8.3"
|
||||
|
|
|
@ -12,6 +12,7 @@ use std::{
|
|||
str,
|
||||
};
|
||||
use sum_tree::{Bias, Dimension, SumTree};
|
||||
use verify::{verify, verify_not};
|
||||
|
||||
pub use offset_utf16::OffsetUtf16;
|
||||
pub use point::Point;
|
||||
|
@ -680,10 +681,11 @@ impl Chunk {
|
|||
let mut offset = 0;
|
||||
let mut point = Point::new(0, 0);
|
||||
for ch in self.0.chars() {
|
||||
if point >= target {
|
||||
if point > target {
|
||||
panic!("point {:?} is inside of character {:?}", target, ch);
|
||||
}
|
||||
verify_not!(point > target, ("point {:?} is inside of character {:?}", target, ch), else {
|
||||
point = target;
|
||||
});
|
||||
|
||||
if point == target {
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue