Skip to content

Commit 1487e26

Browse files
quark-zjufacebook-github-bot
authored andcommitted
dag: rename binary_search_by to bsearch_by
Summary: The name is being taken by stdlib: warning: a method with this name may be added to the standard library in the future --> eden/scm/lib/dag/src/spanset.rs:228:14 | 228 | .binary_search_by(|probe| span.low.cmp(&probe.low)) | ^^^^^^^^^^^^^^^^ | = note: `#[warn(unstable_name_collisions)]` on by default = warning: once this method is added to the standard library, the ambiguity may cause an error or change in behavior! = note: for more information, see issue #48919 <rust-lang/rust#48919> = help: call with fully qualified syntax `BinarySearchBy::binary_search_by(...)` to keep using the current method = help: add `#![feature(vecdeque_binary_search)]` to the crate attributes to enable `VecDeque::<T>::binary_search_by` Reviewed By: sfilipco Differential Revision: D26092424 fbshipit-source-id: d2cdf7d73d2f808f038817c9dc9f4c531ff643bd
1 parent 005328c commit 1487e26

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

eden/scm/lib/dag/src/bsearch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ pub trait BinarySearchBy<T> {
2828
/// one of the matches could be returned. If the value is not found then
2929
/// [`Result::Err`] is returned, containing the index where a matching
3030
/// element could be inserted while maintaining sorted order.
31-
fn binary_search_by<F>(&self, f: F) -> Result<usize, usize>
31+
fn bsearch_by<F>(&self, f: F) -> Result<usize, usize>
3232
where
3333
F: FnMut(&T) -> Ordering;
3434
}
3535

3636
impl<T> BinarySearchBy<T> for VecDeque<T> {
37-
fn binary_search_by<F>(&self, mut f: F) -> Result<usize, usize>
37+
fn bsearch_by<F>(&self, mut f: F) -> Result<usize, usize>
3838
where
3939
F: FnMut(&T) -> Ordering,
4040
{

eden/scm/lib/dag/src/spanset.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,7 @@ impl SpanSet {
223223
/// Tests if a given [`Id`] or [`Span`] is covered by this set.
224224
pub fn contains(&self, value: impl Into<Span>) -> bool {
225225
let span = value.into();
226-
let idx = match self
227-
.spans
228-
.binary_search_by(|probe| span.low.cmp(&probe.low))
229-
{
226+
let idx = match self.spans.bsearch_by(|probe| span.low.cmp(&probe.low)) {
230227
Ok(idx) => idx,
231228
Err(idx) => idx,
232229
};
@@ -467,10 +464,7 @@ impl SpanSet {
467464
/// This is not a general purpose API, but useful for internal logic
468465
/// like DAG descendant calculation.
469466
pub(crate) fn intersection_span_min(&self, rhs: Span) -> Option<Id> {
470-
let i = match self
471-
.spans
472-
.binary_search_by(|probe| rhs.low.cmp(&probe.high))
473-
{
467+
let i = match self.spans.bsearch_by(|probe| rhs.low.cmp(&probe.high)) {
474468
Ok(idx) => idx,
475469
Err(idx) => idx.max(1) - 1,
476470
};

0 commit comments

Comments
 (0)