on master help sign in
use partition_point instead of binary_search_by
7cf448ePascal Kuthe
helix-core/src/text_annotations.rs+1−4
@@ -1,5 +1,4 @@
1use std::cell::Cell;
1use std::cell::Cell;
2−use std::convert::identity;
3use std::ops::Range;
2use std::ops::Range;
4use std::rc::Rc;
3use std::rc::Rc;
5
4
@@ -113,9 +112,7 @@ impl<A, M> Layer<A, M> {
113 pub fn reset_pos(&self, char_idx: usize, get_char_idx: impl Fn(&A) -> usize) {
112 pub fn reset_pos(&self, char_idx: usize, get_char_idx: impl Fn(&A) -> usize) {
114 let new_index = self
113 let new_index = self
115 .annotations
114 .annotations
116− .binary_search_by_key(&char_idx, get_char_idx)
115+ .partition_point(|annot| get_char_idx(annot) < char_idx);
117− .unwrap_or_else(identity);
118−
119 self.current_index.set(new_index);
116 self.current_index.set(new_index);
120 }
117 }
121
118