@@ -44,8 +44,8 @@ impl TextRange {
4444 /// assert_eq!(range.len(), end - start);
4545 /// ```
4646 #[ inline]
47- pub fn new ( start : TextSize , end : TextSize ) -> TextRange {
48- assert ! ( start <= end) ;
47+ pub const fn new ( start : TextSize , end : TextSize ) -> TextRange {
48+ assert ! ( start. raw <= end. raw ) ;
4949 TextRange { start, end }
5050 }
5151
@@ -65,8 +65,8 @@ impl TextRange {
6565 /// assert_eq!(&text[range], "23456")
6666 /// ```
6767 #[ inline]
68- pub fn at ( offset : TextSize , len : TextSize ) -> TextRange {
69- TextRange :: new ( offset, offset + len)
68+ pub const fn at ( offset : TextSize , len : TextSize ) -> TextRange {
69+ TextRange :: new ( offset, TextSize :: new ( offset. raw + len. raw ) )
7070 }
7171
7272 /// Create a zero-length range at the specified offset (`offset..offset`).
@@ -82,7 +82,7 @@ impl TextRange {
8282 /// assert_eq!(range, TextRange::new(point, point));
8383 /// ```
8484 #[ inline]
85- pub fn empty ( offset : TextSize ) -> TextRange {
85+ pub const fn empty ( offset : TextSize ) -> TextRange {
8686 TextRange {
8787 start : offset,
8888 end : offset,
@@ -104,9 +104,9 @@ impl TextRange {
104104 /// assert_eq!(range, TextRange::at(0.into(), point));
105105 /// ```
106106 #[ inline]
107- pub fn up_to ( end : TextSize ) -> TextRange {
107+ pub const fn up_to ( end : TextSize ) -> TextRange {
108108 TextRange {
109- start : 0 . into ( ) ,
109+ start : TextSize :: new ( 0 ) ,
110110 end,
111111 }
112112 }
0 commit comments