@@ -41,18 +41,19 @@ impl fmt::Debug for TextRange {
41
41
}
42
42
}
43
43
44
+ /// Creates a new `TextRange` with given `start` and `end.
45
+ ///
46
+ /// # Panics
47
+ ///
48
+ /// Panics if `end < start`.
49
+ #[ allow( non_snake_case) ]
50
+ pub fn TextRange ( start : TextSize , end : TextSize ) -> TextRange {
51
+ assert ! ( start <= end) ;
52
+ TextRange { start, end }
53
+ }
54
+
44
55
/// Identity methods.
45
56
impl TextRange {
46
- /// Creates a new `TextRange` with given `start` and `end.
47
- ///
48
- /// # Panics
49
- ///
50
- /// Panics if `end < start`.
51
- pub fn new ( start : TextSize , end : TextSize ) -> TextRange {
52
- assert ! ( start <= end) ;
53
- TextRange { start, end }
54
- }
55
-
56
57
/// The start point of this range.
57
58
pub const fn start ( self ) -> TextSize {
58
59
self . start
@@ -94,14 +95,14 @@ impl TextRange {
94
95
if end < start {
95
96
return None ;
96
97
}
97
- Some ( TextRange :: new ( start, end) )
98
+ Some ( TextRange ( start, end) )
98
99
}
99
100
100
101
/// The smallest range that completely contains both ranges.
101
102
pub fn covering ( lhs : TextRange , rhs : TextRange ) -> TextRange {
102
103
let start = cmp:: min ( lhs. start ( ) , rhs. start ( ) ) ;
103
104
let end = cmp:: max ( lhs. end ( ) , rhs. end ( ) ) ;
104
- TextRange :: new ( start, end)
105
+ TextRange ( start, end)
105
106
}
106
107
107
108
/// Check if this range contains a point.
0 commit comments