File tree Expand file tree Collapse file tree 1 file changed +19
-8
lines changed Expand file tree Collapse file tree 1 file changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -220,14 +220,6 @@ pub struct TextRange {
220
220
end : TextUnit ,
221
221
}
222
222
223
- impl TextRange {
224
- #[ inline( always) ]
225
- pub fn checked_sub ( self , other : TextUnit ) -> Option < TextRange > {
226
- let res = TextRange :: offset_len ( self . start ( ) . checked_sub ( other) ?, self . len ( ) ) ;
227
- Some ( res)
228
- }
229
- }
230
-
231
223
impl fmt:: Debug for TextRange {
232
224
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
233
225
<Self as fmt:: Display >:: fmt ( self , f)
@@ -307,6 +299,25 @@ impl TextRange {
307
299
pub fn contains_inclusive ( & self , offset : TextUnit ) -> bool {
308
300
self . start ( ) <= offset && offset <= self . end ( )
309
301
}
302
+
303
+ #[ inline( always) ]
304
+ pub fn checked_sub ( self , other : TextUnit ) -> Option < TextRange > {
305
+ let res = TextRange :: offset_len (
306
+ self . start ( ) . checked_sub ( other) ?,
307
+ self . len ( )
308
+ ) ;
309
+ Some ( res)
310
+ }
311
+ }
312
+
313
+ impl ops:: RangeBounds < TextUnit > for TextRange {
314
+ fn start_bound ( & self ) -> ops:: Bound < & TextUnit > {
315
+ ops:: Bound :: Included ( & self . start )
316
+ }
317
+
318
+ fn end_bound ( & self ) -> ops:: Bound < & TextUnit > {
319
+ ops:: Bound :: Excluded ( & self . end )
320
+ }
310
321
}
311
322
312
323
impl ops:: Index < TextRange > for str {
You can’t perform that action at this time.
0 commit comments