Runnig tests somehow

This commit is contained in:
Aleksey Kladov 2018-08-24 13:41:25 +03:00
parent 89e56c364f
commit 6cade3f6d8
10 changed files with 149 additions and 32 deletions

View file

@ -0,0 +1,19 @@
use {TextRange, TextUnit};
pub fn contains_offset_nonstrict(range: TextRange, offset: TextUnit) -> bool {
range.start() <= offset && offset <= range.end()
}
pub fn is_subrange(range: TextRange, subrange: TextRange) -> bool {
range.start() <= subrange.start() && subrange.end() <= range.end()
}
pub fn intersect(r1: TextRange, r2: TextRange) -> Option<TextRange> {
let start = r1.start().max(r2.start());
let end = r1.end().min(r2.end());
if start <= end {
Some(TextRange::from_to(start, end))
} else {
None
}
}