Skip to content

Commit 74e7422

Browse files
bors[bot]matklad
andauthored
Merge #5942
5942: Actually assert disjointness r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents a000346 + 9684daa commit 74e7422

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

crates/text_edit/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl TextEdit {
119119
return Err(other);
120120
}
121121
self.indels.extend(other.indels);
122-
assert!(check_disjoint(&mut self.indels));
122+
assert_disjoint(&mut self.indels);
123123
Ok(())
124124
}
125125

@@ -169,7 +169,7 @@ impl TextEditBuilder {
169169
}
170170
pub fn finish(self) -> TextEdit {
171171
let mut indels = self.indels;
172-
assert!(check_disjoint(&mut indels));
172+
assert_disjoint(&mut indels);
173173
TextEdit { indels }
174174
}
175175
pub fn invalidates_offset(&self, offset: TextSize) -> bool {
@@ -178,11 +178,14 @@ impl TextEditBuilder {
178178
fn indel(&mut self, indel: Indel) {
179179
self.indels.push(indel);
180180
if self.indels.len() <= 16 {
181-
check_disjoint(&mut self.indels);
181+
assert_disjoint(&mut self.indels);
182182
}
183183
}
184184
}
185185

186+
fn assert_disjoint(indels: &mut [impl std::borrow::Borrow<Indel>]) {
187+
assert!(check_disjoint(indels));
188+
}
186189
fn check_disjoint(indels: &mut [impl std::borrow::Borrow<Indel>]) -> bool {
187190
indels.sort_by_key(|indel| (indel.borrow().delete.start(), indel.borrow().delete.end()));
188191
indels

0 commit comments

Comments
 (0)