mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-03 18:29:23 +00:00
Simplify highlighting infra
This also fixes the killer whale bug
This commit is contained in:
parent
981a0d708e
commit
e30c1c3fbf
11 changed files with 287 additions and 276 deletions
|
@ -1,5 +1,5 @@
|
|||
//! Missing batteries for standard libraries.
|
||||
use std::{ops, process, time::Instant};
|
||||
use std::{cmp::Ordering, ops, process, time::Instant};
|
||||
|
||||
mod macros;
|
||||
pub mod panic_context;
|
||||
|
@ -117,7 +117,12 @@ impl<'a> Iterator for LinesWithEnds<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/73831
|
||||
/// Returns `idx` such that:
|
||||
///
|
||||
/// ∀ x in slice[..idx]: pred(x)
|
||||
/// && ∀ x in slice[idx..]: !pred(x)
|
||||
///
|
||||
/// https://github.com/rust-lang/rust/issues/73831
|
||||
pub fn partition_point<T, P>(slice: &[T], mut pred: P) -> usize
|
||||
where
|
||||
P: FnMut(&T) -> bool,
|
||||
|
@ -147,6 +152,15 @@ where
|
|||
left
|
||||
}
|
||||
|
||||
pub fn equal_range_by<T, F>(slice: &[T], mut key: F) -> (usize, usize)
|
||||
where
|
||||
F: FnMut(&T) -> Ordering,
|
||||
{
|
||||
let start = partition_point(slice, |it| key(it) == Ordering::Less);
|
||||
let len = partition_point(&slice[start..], |it| key(it) == Ordering::Equal);
|
||||
(start, len)
|
||||
}
|
||||
|
||||
pub struct JodChild(pub process::Child);
|
||||
|
||||
impl ops::Deref for JodChild {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue