diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-23 12:01:29 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-23 12:01:29 +0100 |
commit | 37e1d1c526e4d777a8e78088d830d73e2c6e0e90 (patch) | |
tree | cbb55f3a07244c087aeb50f4e798c56acfecad7d /crates/ra_ide_db/src | |
parent | 8a49f937936e7c7a886fc859905bb40f53bc47e3 (diff) | |
parent | 4f7a3fba59269a2b37b78655a10778ba5af796bd (diff) |
Merge #5503
5503: Replace superslice with API on path to stabilization r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_db/src')
-rw-r--r-- | crates/ra_ide_db/src/line_index.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/ra_ide_db/src/line_index.rs b/crates/ra_ide_db/src/line_index.rs index c7c744fce..2ab662098 100644 --- a/crates/ra_ide_db/src/line_index.rs +++ b/crates/ra_ide_db/src/line_index.rs | |||
@@ -4,7 +4,7 @@ use std::iter; | |||
4 | 4 | ||
5 | use ra_syntax::{TextRange, TextSize}; | 5 | use ra_syntax::{TextRange, TextSize}; |
6 | use rustc_hash::FxHashMap; | 6 | use rustc_hash::FxHashMap; |
7 | use superslice::Ext; | 7 | use stdx::partition_point; |
8 | 8 | ||
9 | #[derive(Clone, Debug, PartialEq, Eq)] | 9 | #[derive(Clone, Debug, PartialEq, Eq)] |
10 | pub struct LineIndex { | 10 | pub struct LineIndex { |
@@ -89,7 +89,7 @@ impl LineIndex { | |||
89 | } | 89 | } |
90 | 90 | ||
91 | pub fn line_col(&self, offset: TextSize) -> LineCol { | 91 | pub fn line_col(&self, offset: TextSize) -> LineCol { |
92 | let line = self.newlines.upper_bound(&offset) - 1; | 92 | let line = partition_point(&self.newlines, |&it| it <= offset) - 1; |
93 | let line_start_offset = self.newlines[line]; | 93 | let line_start_offset = self.newlines[line]; |
94 | let col = offset - line_start_offset; | 94 | let col = offset - line_start_offset; |
95 | 95 | ||
@@ -103,8 +103,8 @@ impl LineIndex { | |||
103 | } | 103 | } |
104 | 104 | ||
105 | pub fn lines(&self, range: TextRange) -> impl Iterator<Item = TextRange> + '_ { | 105 | pub fn lines(&self, range: TextRange) -> impl Iterator<Item = TextRange> + '_ { |
106 | let lo = self.newlines.lower_bound(&range.start()); | 106 | let lo = partition_point(&self.newlines, |&it| it < range.start()); |
107 | let hi = self.newlines.upper_bound(&range.end()); | 107 | let hi = partition_point(&self.newlines, |&it| it <= range.end()); |
108 | let all = iter::once(range.start()) | 108 | let all = iter::once(range.start()) |
109 | .chain(self.newlines[lo..hi].iter().copied()) | 109 | .chain(self.newlines[lo..hi].iter().copied()) |
110 | .chain(iter::once(range.end())); | 110 | .chain(iter::once(range.end())); |