Unnamed repository; edit this file 'description' to name the repository.
Merge rust-analyzer/text-size#30
30: Don't use decimal numbers when str length overflows TextSize. r=matklad a=CAD97 Since the string is necessarily longer than 4,294,967,296 bytes, it is probably more useful to output the length in hexadecimal. For additional niceness, we output the first and last 10 characters. Co-authored-by: CAD97 <[email protected]>
bors[bot] 2020-03-26
parent 84d071b · parent 0f09f1d · commit d19a5a3
-rw-r--r--lib/text-size/src/traits.rs4
1 files changed, 1 insertions, 3 deletions
diff --git a/lib/text-size/src/traits.rs b/lib/text-size/src/traits.rs
index 745675fda7..65f6445a1e 100644
--- a/lib/text-size/src/traits.rs
+++ b/lib/text-size/src/traits.rs
@@ -12,9 +12,7 @@ pub trait LenTextSize: Copy {
impl LenTextSize for &'_ str {
#[inline]
fn len_text_size(self) -> TextSize {
- self.len()
- .try_into()
- .unwrap_or_else(|_| panic!("string too large ({}) for TextSize", self.len()))
+ self.len().try_into().unwrap()
}
}