From cad61d2620e7dadc78ceaf155cf792ed945c2b79 Mon Sep 17 00:00:00 2001 From: konstin Date: Mon, 26 Jun 2023 13:55:35 +0200 Subject: [PATCH] impl Ranged for &T where T: Ranged (#16) 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() }); ``` --- ast/src/ranged.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ast/src/ranged.rs b/ast/src/ranged.rs index f01c15a7..b20d7114 100644 --- a/ast/src/ranged.rs +++ b/ast/src/ranged.rs @@ -14,4 +14,13 @@ pub trait Ranged { } } +impl Ranged for &T +where + T: Ranged, +{ + fn range(&self) -> TextRange { + T::range(self) + } +} + include!("gen/ranged.rs");