From 61a49c89eb809a238b01616b0a50a0f785702891 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Tue, 16 Sep 2025 12:41:11 -0400 Subject: [PATCH] [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. --- crates/ruff_text_size/src/range.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/ruff_text_size/src/range.rs b/crates/ruff_text_size/src/range.rs index 895cfea530..302568e8e3 100644 --- a/crates/ruff_text_size/src/range.rs +++ b/crates/ruff_text_size/src/range.rs @@ -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 { + (*self).into() + } +} + impl Index for str { type Output = str; #[inline]