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

Commit

Permalink
impl<T> Ranged for &T where T: Ranged (#16)
Browse files Browse the repository at this point in the history
In the example below, `arg` is `&Expr`, so `&Ranged`, but `entries()`
want a `T: Ranged`. This adds the missing bridge impl.

```rust
        let all_args = format_with(|f| {
            f.join_comma_separated()
                .entries(
                    // We have the parentheses from the call so the arguments never need any
                    args.iter()
                        .map(|arg| (arg, arg.format().with_options(Parenthesize::Never))),
                )
                .nodes(keywords.iter())
                .finish()
        });
```
  • Loading branch information
konstin authored and zanieb committed Jul 17, 2023
1 parent a95112d commit cad61d2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ast/src/ranged.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,13 @@ pub trait Ranged {
}
}

impl<T> Ranged for &T
where
T: Ranged,
{
fn range(&self) -> TextRange {
T::range(self)
}
}

include!("gen/ranged.rs");

0 comments on commit cad61d2

Please sign in to comment.