diff --git a/crates/ruff_formatter/shared_traits.rs b/crates/ruff_formatter/shared_traits.rs index f427934f31..aab0120ea7 100644 --- a/crates/ruff_formatter/shared_traits.rs +++ b/crates/ruff_formatter/shared_traits.rs @@ -44,6 +44,18 @@ where } } +/// Implement [`IntoFormat`] for references to types that implement [`AsFormat`]. +impl<'a, T, C> IntoFormat for &'a T +where + T: AsFormat, +{ + type Format = T::Format<'a>; + + fn into_format(self) -> Self::Format { + AsFormat::format(self) + } +} + /// Formatting specific [`Iterator`] extensions pub trait FormattedIterExt { /// Converts every item to an object that knows how to format it.