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.rs25
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/text-size/src/range.rs b/lib/text-size/src/range.rs
index 8febcad082..7e01b12e9f 100644
--- a/lib/text-size/src/range.rs
+++ b/lib/text-size/src/range.rs
@@ -41,18 +41,19 @@ impl fmt::Debug for TextRange {
}
}
+/// Creates a new `TextRange` with given `start` and `end.
+///
+/// # Panics
+///
+/// Panics if `end < start`.
+#[allow(non_snake_case)]
+pub fn TextRange(start: TextSize, end: TextSize) -> TextRange {
+ assert!(start <= end);
+ TextRange { start, end }
+}
+
/// Identity methods.
impl TextRange {
- /// Creates a new `TextRange` with given `start` and `end.
- ///
- /// # Panics
- ///
- /// Panics if `end < start`.
- pub fn new(start: TextSize, end: TextSize) -> TextRange {
- assert!(start <= end);
- TextRange { start, end }
- }
-
/// The start point of this range.
pub const fn start(self) -> TextSize {
self.start
@@ -94,14 +95,14 @@ impl TextRange {
if end < start {
return None;
}
- Some(TextRange::new(start, end))
+ Some(TextRange(start, end))
}
/// The smallest range that completely contains both ranges.
pub fn covering(lhs: TextRange, rhs: TextRange) -> TextRange {
let start = cmp::min(lhs.start(), rhs.start());
let end = cmp::max(lhs.end(), rhs.end());
- TextRange::new(start, end)
+ TextRange(start, end)
}
/// Check if this range contains a point.