File tree Expand file tree Collapse file tree 3 files changed +13
-24
lines changed Expand file tree Collapse file tree 3 files changed +13
-24
lines changed Original file line number Diff line number Diff line change @@ -98,8 +98,8 @@ impl TextRange {
9898 /// let range = TextRange::up_to(point);
9999 ///
100100 /// assert_eq!(range.len(), point);
101- /// assert_eq!(range, TextRange::new(TextSize::zero (), point));
102- /// assert_eq!(range, TextRange::at(TextSize::zero (), point));
101+ /// assert_eq!(range, TextRange::new(0.into (), point));
102+ /// assert_eq!(range, TextRange::at(0.into (), point));
103103 /// ```
104104 #[ inline]
105105 pub fn up_to ( end : TextSize ) -> TextRange {
@@ -254,7 +254,7 @@ impl TextRange {
254254 /// ```rust
255255 /// # use text_size::*;
256256 /// assert_eq!(
257- /// TextRange::empty(TextSize::zero ()).cover_offset(20.into()),
257+ /// TextRange::empty(0.into ()).cover_offset(20.into()),
258258 /// TextRange::new(0.into(), 20.into()),
259259 /// )
260260 /// ```
Original file line number Diff line number Diff line change 1- use {
2- std:: { borrow:: Cow , sync:: Arc } ,
3- text_size:: * ,
4- } ;
1+ use text_size:: TextSize ;
52
63#[ derive( Copy , Clone ) ]
74struct BadRope < ' a > ( & ' a [ & ' a str ] ) ;
85
96impl BadRope < ' _ > {
107 fn text_len ( self ) -> TextSize {
11- self . 0 . iter ( ) . map ( TextSize :: of) . sum ( )
8+ self . 0 . iter ( ) . copied ( ) . map ( TextSize :: of) . sum ( )
129 }
1310}
1411
1512#[ test]
1613fn main ( ) {
17- macro_rules! test {
18- ( $( $expr: expr) ,+ $( , ) ?) => {
19- $( let _ = TextSize :: of( $expr) ; ) +
20- } ;
21- }
14+ let x: char = 'c' ;
15+ let _ = TextSize :: of ( x) ;
2216
23- test ! {
24- "" ,
25- & "" ,
26- 'a' ,
27- & 'a' ,
28- & String :: new( ) ,
29- & String :: new( ) . into_boxed_str( ) ,
30- & Arc :: new( String :: new( ) ) ,
31- & Cow :: Borrowed ( "" ) ,
32- }
17+ let x: & str = "hello" ;
18+ let _ = TextSize :: of ( x) ;
19+
20+ let x: & String = & "hello" . into ( ) ;
21+ let _ = TextSize :: of ( x) ;
3322
3423 let _ = BadRope ( & [ "" ] ) . text_len ( ) ;
3524}
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ fn checked_math() {
2626 assert_eq ! ( size( 1 ) . checked_add( size( 1 ) ) , Some ( size( 2 ) ) ) ;
2727 assert_eq ! ( size( 1 ) . checked_sub( size( 1 ) ) , Some ( size( 0 ) ) ) ;
2828 assert_eq ! ( size( 1 ) . checked_sub( size( 2 ) ) , None ) ;
29- assert_eq ! ( TextSize :: MAX . checked_add( size( 1 ) ) , None ) ;
29+ assert_eq ! ( size ( ! 0 ) . checked_add( size( 1 ) ) , None ) ;
3030}
3131
3232#[ test]
You can’t perform that action at this time.
0 commit comments