Skip to content

Commit bcf499f

Browse files
committed
Bound the cursor by PartialOrd instead of using is_range_empty().
1 parent 3d48148 commit bcf499f

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

text/0000-os-str-pattern.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,8 @@ pub trait DoubleEndedSearcher<H: Haystack>: ReverseSearcher<H> {}
407407
// equivalent to SearchPtrs in "Pattern API 1.5"
408408
// and PatternHaystack in "Pattern API 2.0"
409409
pub trait Haystack: Sized {
410-
type StartCursor: Copy;
411-
type EndCursor: Copy;
410+
type StartCursor: Copy + PartialOrd<Self::EndCursor>;
411+
type EndCursor: Copy + PartialOrd<Self::StartCursor>;
412412
413413
// The following 5 methods are same as those in "Pattern API 1.5"
414414
// except the cursor type is split into two.
@@ -418,9 +418,6 @@ pub trait Haystack: Sized {
418418
unsafe fn end_cursor_to_offset(hs: &Self, cur: Self::EndCursor) -> usize;
419419
unsafe fn range_to_self(hs: Self, start: Self::StartCursor, end: Self::EndCursor) -> Self;
420420
421-
// Since a StartCursor and EndCursor may not be comparable, we also need this method
422-
fn is_range_empty(start: Self::StartCursor, end: Self::EndCursor) -> bool;
423-
424421
// And then we want to swap between the two cursor types
425422
unsafe fn start_to_end_cursor(hs: &Self, cur: Self::StartCursor) -> Self::EndCursor;
426423
unsafe fn end_to_start_cursor(hs: &Self, cur: Self::EndCursor) -> Self::StartCursor;

0 commit comments

Comments
 (0)