Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'lib/text-size/src/range.rs')
-rw-r--r--lib/text-size/src/range.rs32
1 files changed, 16 insertions, 16 deletions
diff --git a/lib/text-size/src/range.rs b/lib/text-size/src/range.rs
index fc0bbc8b47..df5296af14 100644
--- a/lib/text-size/src/range.rs
+++ b/lib/text-size/src/range.rs
@@ -88,8 +88,23 @@ impl TextRange {
/// Manipulation methods.
impl TextRange {
+ /// Check if this range contains an offset.
+ ///
+ /// The end index is considered excluded.
+ pub fn contains(self, offset: TextSize) -> bool {
+ self.start() <= offset && offset < self.end()
+ }
+
+ /// Check if this range contains an offset.
+ ///
+ /// The end index is considered included.
+ pub fn contains_inclusive(self, offset: TextSize) -> bool {
+ let point = offset.into();
+ self.start() <= point && point <= self.end()
+ }
+
/// Check if this range completely contains another range.
- pub fn contains(self, other: TextRange) -> bool {
+ pub fn contains_range(self, other: TextRange) -> bool {
self.start() <= other.start() && other.end() <= self.end()
}
@@ -110,21 +125,6 @@ impl TextRange {
let end = cmp::max(lhs.end(), rhs.end());
TextRange(start, end)
}
-
- /// Check if this range contains an offset.
- ///
- /// The end index is considered excluded.
- pub fn contains_exclusive(self, offset: TextSize) -> bool {
- self.start() <= offset && offset < self.end()
- }
-
- /// Check if this range contains an offset.
- ///
- /// The end index is considered included.
- pub fn contains_inclusive(self, offset: TextSize) -> bool {
- let point = offset.into();
- self.start() <= point && point <= self.end()
- }
}
impl Index<TextRange> for str {