Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'lib/text-size/src/traits.rs')
| -rw-r--r-- | lib/text-size/src/traits.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/text-size/src/traits.rs b/lib/text-size/src/traits.rs index 6f3462bee5..745675fda7 100644 --- a/lib/text-size/src/traits.rs +++ b/lib/text-size/src/traits.rs @@ -4,33 +4,33 @@ use { }; /// Text-like structures that have a text size. -pub trait TextSized: Copy { +pub trait LenTextSize: Copy { /// The size of this text-alike. - fn text_size(self) -> TextSize; + fn len_text_size(self) -> TextSize; } -impl TextSized for &'_ str { +impl LenTextSize for &'_ str { #[inline] - fn text_size(self) -> TextSize { + fn len_text_size(self) -> TextSize { self.len() .try_into() .unwrap_or_else(|_| panic!("string too large ({}) for TextSize", self.len())) } } -impl<D> TextSized for &'_ D +impl<D> LenTextSize for &'_ D where D: Deref<Target = str>, { #[inline] - fn text_size(self) -> TextSize { - self.deref().text_size() + fn len_text_size(self) -> TextSize { + self.deref().len_text_size() } } -impl TextSized for char { +impl LenTextSize for char { #[inline] - fn text_size(self) -> TextSize { + fn len_text_size(self) -> TextSize { (self.len_utf8() as u32).into() } } |