Implement Ranged on more structs (#6921)

Now that it's in `ruff_text_size`, we can use it in a few places that we
couldn't before.
This commit is contained in:
Charlie Marsh 2023-08-27 15:03:08 -04:00 committed by GitHub
parent fc89976c24
commit 059757a8c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 104 additions and 115 deletions

View file

@ -1,7 +1,7 @@
use memchr::{memchr2, memchr3, memrchr3_iter};
use unic_ucd_ident::{is_xid_continue, is_xid_start};
use ruff_text_size::{TextLen, TextRange, TextSize};
use ruff_text_size::{Ranged, TextLen, TextRange, TextSize};
use crate::{is_python_whitespace, Cursor};
@ -131,19 +131,12 @@ impl SimpleToken {
pub const fn kind(&self) -> SimpleTokenKind {
self.kind
}
}
#[allow(unused)]
pub const fn range(&self) -> TextRange {
impl Ranged for SimpleToken {
fn range(&self) -> TextRange {
self.range
}
pub const fn start(&self) -> TextSize {
self.range.start()
}
pub const fn end(&self) -> TextSize {
self.range.end()
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]