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 {
98
98
/// let range = TextRange::up_to(point);
99
99
///
100
100
/// 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));
103
103
/// ```
104
104
#[ inline]
105
105
pub fn up_to ( end : TextSize ) -> TextRange {
@@ -254,7 +254,7 @@ impl TextRange {
254
254
/// ```rust
255
255
/// # use text_size::*;
256
256
/// assert_eq!(
257
- /// TextRange::empty(TextSize::zero ()).cover_offset(20.into()),
257
+ /// TextRange::empty(0.into ()).cover_offset(20.into()),
258
258
/// TextRange::new(0.into(), 20.into()),
259
259
/// )
260
260
/// ```
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 ;
5
2
6
3
#[ derive( Copy , Clone ) ]
7
4
struct BadRope < ' a > ( & ' a [ & ' a str ] ) ;
8
5
9
6
impl BadRope < ' _ > {
10
7
fn text_len ( self ) -> TextSize {
11
- self . 0 . iter ( ) . map ( TextSize :: of) . sum ( )
8
+ self . 0 . iter ( ) . copied ( ) . map ( TextSize :: of) . sum ( )
12
9
}
13
10
}
14
11
15
12
#[ test]
16
13
fn 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) ;
22
16
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) ;
33
22
34
23
let _ = BadRope ( & [ "" ] ) . text_len ( ) ;
35
24
}
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ fn checked_math() {
26
26
assert_eq ! ( size( 1 ) . checked_add( size( 1 ) ) , Some ( size( 2 ) ) ) ;
27
27
assert_eq ! ( size( 1 ) . checked_sub( size( 1 ) ) , Some ( size( 0 ) ) ) ;
28
28
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 ) ;
30
30
}
31
31
32
32
#[ test]
You can’t perform that action at this time.
0 commit comments