File tree Expand file tree Collapse file tree 3 files changed +13
-13
lines changed Expand file tree Collapse file tree 3 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ mod traits;
12
12
#[ cfg( feature = "serde" ) ]
13
13
mod serde_impls;
14
14
15
- pub use crate :: { range:: TextRange , size:: TextSize , traits:: TextSized } ;
15
+ pub use crate :: { range:: TextRange , size:: TextSize , traits:: LenTextSize } ;
16
16
17
17
#[ cfg( target_pointer_width = "16" ) ]
18
18
compile_error ! ( "text-size assumes usize >= u32 and does not work on 16-bit targets" ) ;
Original file line number Diff line number Diff line change 1
1
use {
2
- crate :: TextSized ,
2
+ crate :: LenTextSize ,
3
3
std:: {
4
4
convert:: TryFrom ,
5
5
fmt, iter,
@@ -57,8 +57,8 @@ impl TextSize {
57
57
/// assert_eq!(str_size, TextSize::from(13));
58
58
/// ```
59
59
#[ inline]
60
- pub fn of ( text : impl TextSized ) -> TextSize {
61
- text. text_size ( )
60
+ pub fn of ( text : impl LenTextSize ) -> TextSize {
61
+ text. len_text_size ( )
62
62
}
63
63
64
64
/// A size of zero.
Original file line number Diff line number Diff line change 4
4
} ;
5
5
6
6
/// Text-like structures that have a text size.
7
- pub trait TextSized : Copy {
7
+ pub trait LenTextSize : Copy {
8
8
/// The size of this text-alike.
9
- fn text_size ( self ) -> TextSize ;
9
+ fn len_text_size ( self ) -> TextSize ;
10
10
}
11
11
12
- impl TextSized for & ' _ str {
12
+ impl LenTextSize for & ' _ str {
13
13
#[ inline]
14
- fn text_size ( self ) -> TextSize {
14
+ fn len_text_size ( self ) -> TextSize {
15
15
self . len ( )
16
16
. try_into ( )
17
17
. unwrap_or_else ( |_| panic ! ( "string too large ({}) for TextSize" , self . len( ) ) )
18
18
}
19
19
}
20
20
21
- impl < D > TextSized for & ' _ D
21
+ impl < D > LenTextSize for & ' _ D
22
22
where
23
23
D : Deref < Target = str > ,
24
24
{
25
25
#[ inline]
26
- fn text_size ( self ) -> TextSize {
27
- self . deref ( ) . text_size ( )
26
+ fn len_text_size ( self ) -> TextSize {
27
+ self . deref ( ) . len_text_size ( )
28
28
}
29
29
}
30
30
31
- impl TextSized for char {
31
+ impl LenTextSize for char {
32
32
#[ inline]
33
- fn text_size ( self ) -> TextSize {
33
+ fn len_text_size ( self ) -> TextSize {
34
34
( self . len_utf8 ( ) as u32 ) . into ( )
35
35
}
36
36
}
You can’t perform that action at this time.
0 commit comments