Remove copied core modules from ruff_python_formatter (#3371)

This commit is contained in:
Charlie Marsh 2023-03-08 14:03:40 -05:00 committed by GitHub
parent 130e733023
commit 0a9d259f9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 105 additions and 273 deletions

View file

@ -133,6 +133,17 @@ impl<'a> Locator<'a> {
&self.contents[start..end]
}
/// Return the byte offset of the given [`Location`].
pub fn offset(&self, location: Location) -> usize {
let index = self.get_or_init_index();
truncate(location, index, self.contents)
}
/// Return the underlying source code.
pub fn contents(&self) -> &'a str {
self.contents
}
pub const fn len(&self) -> usize {
self.contents.len()
}