mirror of https://github.com/astral-sh/ruff
[ruff] Add `TextRange::to_std_range`
This can already be accomplished via a `From` impl (and indeed, that's how this is implemented). But in a generic context, the turbo-fishing that needs to be applied is quite annoying.
This commit is contained in:
parent
da5eb85087
commit
61a49c89eb
|
|
@ -425,6 +425,22 @@ impl TextRange {
|
|||
}
|
||||
}
|
||||
|
||||
/// Conversion methods.
|
||||
impl TextRange {
|
||||
/// A convenience routine for converting this range to a
|
||||
/// standard library range that satisfies the `RangeBounds`
|
||||
/// trait.
|
||||
///
|
||||
/// This is also available as a `From` trait implementation,
|
||||
/// but this method avoids the need to specify types to help
|
||||
/// inference.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn to_std_range(&self) -> Range<usize> {
|
||||
(*self).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl Index<TextRange> for str {
|
||||
type Output = str;
|
||||
#[inline]
|
||||
|
|
|
|||
Loading…
Reference in New Issue