Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Commit

Permalink
impl Ranged for TextRange (#20)
Browse files Browse the repository at this point in the history
This adds the missing implementation of `Ranged` for `TextRange` itself

```rust
impl Ranged for TextRange {
    fn range(&self) -> TextRange {
        *self
    }
}
```

This allows e.g. using `has_comments` with arbitrary ranges instead of
just a node.

It also adds .venv to the .gitignore
  • Loading branch information
konstin authored Jul 2, 2023
1 parent c174bbf commit 0f2e295
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ __pycache__
.*sw*
.vscode
.idea/
.venv/

flame-graph.html
flame.txt
Expand Down
6 changes: 6 additions & 0 deletions ast/src/ranged.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ pub trait Ranged {
}
}

impl Ranged for TextRange {
fn range(&self) -> TextRange {
*self
}
}

impl<T> Ranged for &T
where
T: Ranged,
Expand Down

0 comments on commit 0f2e295

Please sign in to comment.