Skip to content

Commit a29d564

Browse files
bors[bot]CAD97
andauthored
Merge #29
29: TextSized is not meant to be used directly... r=matklad a=CAD97 so rename it to a name more distinct from TextSize. Co-authored-by: CAD97 <[email protected]>
2 parents 73ad7ea + 8951ec1 commit a29d564

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mod traits;
1212
#[cfg(feature = "serde")]
1313
mod serde_impls;
1414

15-
pub use crate::{range::TextRange, size::TextSize, traits::TextSized};
15+
pub use crate::{range::TextRange, size::TextSize, traits::LenTextSize};
1616

1717
#[cfg(target_pointer_width = "16")]
1818
compile_error!("text-size assumes usize >= u32 and does not work on 16-bit targets");

src/size.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use {
2-
crate::TextSized,
2+
crate::LenTextSize,
33
std::{
44
convert::TryFrom,
55
fmt, iter,
@@ -57,8 +57,8 @@ impl TextSize {
5757
/// assert_eq!(str_size, TextSize::from(13));
5858
/// ```
5959
#[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()
6262
}
6363

6464
/// A size of zero.

src/traits.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@ use {
44
};
55

66
/// Text-like structures that have a text size.
7-
pub trait TextSized: Copy {
7+
pub trait LenTextSize: Copy {
88
/// The size of this text-alike.
9-
fn text_size(self) -> TextSize;
9+
fn len_text_size(self) -> TextSize;
1010
}
1111

12-
impl TextSized for &'_ str {
12+
impl LenTextSize for &'_ str {
1313
#[inline]
14-
fn text_size(self) -> TextSize {
14+
fn len_text_size(self) -> TextSize {
1515
self.len()
1616
.try_into()
1717
.unwrap_or_else(|_| panic!("string too large ({}) for TextSize", self.len()))
1818
}
1919
}
2020

21-
impl<D> TextSized for &'_ D
21+
impl<D> LenTextSize for &'_ D
2222
where
2323
D: Deref<Target = str>,
2424
{
2525
#[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()
2828
}
2929
}
3030

31-
impl TextSized for char {
31+
impl LenTextSize for char {
3232
#[inline]
33-
fn text_size(self) -> TextSize {
33+
fn len_text_size(self) -> TextSize {
3434
(self.len_utf8() as u32).into()
3535
}
3636
}

0 commit comments

Comments
 (0)