mirror of
https://github.com/astral-sh/ruff
synced 2026-01-22 05:51:03 -05:00
Implement From<Located> for Range (#3377)
This commit is contained in:
@@ -125,8 +125,9 @@ impl<'a> Locator<'a> {
|
||||
}
|
||||
|
||||
/// Take the source code between the given [`Range`].
|
||||
pub fn slice(&self, range: Range) -> &'a str {
|
||||
pub fn slice<R: Into<Range>>(&self, range: R) -> &'a str {
|
||||
let index = self.get_or_init_index();
|
||||
let range = range.into();
|
||||
let start = truncate(range.location, index, self.contents);
|
||||
let end = truncate(range.end_location, index, self.contents);
|
||||
&self.contents[start..end]
|
||||
|
||||
Reference in New Issue
Block a user