diff --git a/src/lib.rs b/src/lib.rs index bf07dda..7d33a8e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -76,7 +76,7 @@ impl From for SpanRange { /// An input that can provide a span of a range of the input. pub trait Span { - fn span(&self, idx: SpanRange) -> O; + fn span>(&self, idx: R) -> O; } /// The interface for types that can peek ahead to the next item. @@ -169,8 +169,8 @@ impl<'a, T: Debug + 'a> Cursor for SliceCursor<'a, T> { } impl<'a, T: Debug + 'a> Span<&'a [T]> for SliceCursor<'a, T> { - fn span(&self, idx: SpanRange) -> &'a [T] { - match idx { + fn span>(&self, idx: R) -> &'a [T] { + match idx.into() { SpanRange::Range(r) => self.source.index(r), SpanRange::RangeTo(r) => self.source.index(r), SpanRange::RangeFrom(r) => self.source.index(r), @@ -293,8 +293,8 @@ impl<'a> From<&'a str> for StrCursor<'a> { } impl<'a> Span<&'a str> for StrCursor<'a> { - fn span(&self, idx: SpanRange) -> &'a str { - match idx { + fn span>(&self, idx: R) -> &'a str { + match idx.into() { SpanRange::Range(r) => self.source.index(r), SpanRange::RangeTo(r) => self.source.index(r), SpanRange::RangeFrom(r) => self.source.index(r),