Unnamed repository; edit this file 'description' to name the repository.
Merge rust-analyzer/text-size#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]>
bors[bot] 2020-03-24
parent d1b0596 · parent ade5c7b · commit 128f45f
-rw-r--r--lib/text-size/src/lib.rs2
-rw-r--r--lib/text-size/src/size.rs6
-rw-r--r--lib/text-size/src/traits.rs18
3 files changed, 13 insertions, 13 deletions
diff --git a/lib/text-size/src/lib.rs b/lib/text-size/src/lib.rs
index e194e2317b..aea1591003 100644
--- a/lib/text-size/src/lib.rs
+++ b/lib/text-size/src/lib.rs
@@ -12,7 +12,7 @@ mod traits;
#[cfg(feature = "serde")]
mod serde_impls;
-pub use crate::{range::TextRange, size::TextSize, traits::TextSized};
+pub use crate::{range::TextRange, size::TextSize, traits::LenTextSize};
#[cfg(target_pointer_width = "16")]
compile_error!("text-size assumes usize >= u32 and does not work on 16-bit targets");
diff --git a/lib/text-size/src/size.rs b/lib/text-size/src/size.rs
index 9a0256e8b2..234e54d888 100644
--- a/lib/text-size/src/size.rs
+++ b/lib/text-size/src/size.rs
@@ -1,5 +1,5 @@
use {
- crate::TextSized,
+ crate::LenTextSize,
std::{
convert::TryFrom,
fmt, iter,
@@ -57,8 +57,8 @@ impl TextSize {
/// assert_eq!(str_size, TextSize::from(13));
/// ```
#[inline]
- pub fn of(text: impl TextSized) -> TextSize {
- text.text_size()
+ pub fn of(text: impl LenTextSize) -> TextSize {
+ text.len_text_size()
}
/// A size of zero.
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()
}
}