From 1487e26e0ded8d844bf399efe4f7e98cf1f06dd8 Mon Sep 17 00:00:00 2001 From: Jun Wu Date: Thu, 28 Jan 2021 11:57:45 -0800 Subject: [PATCH] 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 = 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::::binary_search_by` Reviewed By: sfilipco Differential Revision: D26092424 fbshipit-source-id: d2cdf7d73d2f808f038817c9dc9f4c531ff643bd --- eden/scm/lib/dag/src/bsearch.rs | 4 ++-- eden/scm/lib/dag/src/spanset.rs | 10 ++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/eden/scm/lib/dag/src/bsearch.rs b/eden/scm/lib/dag/src/bsearch.rs index 253df6ac4826e..8bec6712a2a00 100644 --- a/eden/scm/lib/dag/src/bsearch.rs +++ b/eden/scm/lib/dag/src/bsearch.rs @@ -28,13 +28,13 @@ pub trait BinarySearchBy { /// one of the matches could be returned. If the value is not found then /// [`Result::Err`] is returned, containing the index where a matching /// element could be inserted while maintaining sorted order. - fn binary_search_by(&self, f: F) -> Result + fn bsearch_by(&self, f: F) -> Result where F: FnMut(&T) -> Ordering; } impl BinarySearchBy for VecDeque { - fn binary_search_by(&self, mut f: F) -> Result + fn bsearch_by(&self, mut f: F) -> Result where F: FnMut(&T) -> Ordering, { diff --git a/eden/scm/lib/dag/src/spanset.rs b/eden/scm/lib/dag/src/spanset.rs index ea100893efea4..166e5894158f7 100644 --- a/eden/scm/lib/dag/src/spanset.rs +++ b/eden/scm/lib/dag/src/spanset.rs @@ -223,10 +223,7 @@ impl SpanSet { /// Tests if a given [`Id`] or [`Span`] is covered by this set. pub fn contains(&self, value: impl Into) -> bool { let span = value.into(); - let idx = match self - .spans - .binary_search_by(|probe| span.low.cmp(&probe.low)) - { + let idx = match self.spans.bsearch_by(|probe| span.low.cmp(&probe.low)) { Ok(idx) => idx, Err(idx) => idx, }; @@ -467,10 +464,7 @@ impl SpanSet { /// This is not a general purpose API, but useful for internal logic /// like DAG descendant calculation. pub(crate) fn intersection_span_min(&self, rhs: Span) -> Option { - let i = match self - .spans - .binary_search_by(|probe| rhs.low.cmp(&probe.high)) - { + let i = match self.spans.bsearch_by(|probe| rhs.low.cmp(&probe.high)) { Ok(idx) => idx, Err(idx) => idx.max(1) - 1, };