Unnamed repository; edit this file 'description' to name the repository.
Re-add Index<TextRange> for String
| -rw-r--r-- | lib/text-size/src/range.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/text-size/src/range.rs b/lib/text-size/src/range.rs index 2ed608aa53..11fe1e702d 100644 --- a/lib/text-size/src/range.rs +++ b/lib/text-size/src/range.rs @@ -305,14 +305,29 @@ impl TextRange { impl Index<TextRange> for str { type Output = str; #[inline] - fn index(&self, index: TextRange) -> &Self::Output { + fn index(&self, index: TextRange) -> &str { + &self[Range::<usize>::from(index)] + } +} + +impl Index<TextRange> for String { + type Output = str; + #[inline] + fn index(&self, index: TextRange) -> &str { &self[Range::<usize>::from(index)] } } impl IndexMut<TextRange> for str { #[inline] - fn index_mut(&mut self, index: TextRange) -> &mut Self::Output { + fn index_mut(&mut self, index: TextRange) -> &mut str { + &mut self[Range::<usize>::from(index)] + } +} + +impl IndexMut<TextRange> for String { + #[inline] + fn index_mut(&mut self, index: TextRange) -> &mut str { &mut self[Range::<usize>::from(index)] } } |