From 19b6e9df202e55b062000653a3057a75200d723f Mon Sep 17 00:00:00 2001 From: Simonas Kazlauskas Date: Fri, 20 Jan 2023 19:40:51 +0200 Subject: [PATCH] VisitOperator: implement delegates for Box This is also fine because `Box` implements DerefMut. Pretty useful for people (like me) who have a `Box $visit:ident)*) => { $( fn $visit(&mut self $($(,$arg: $argty)*)?) -> Self::Output { - V::$visit(*self, $($($arg),*)?) + V::$visit(&mut *self, $($($arg),*)?) } )* } } -impl<'a, 'b, V: VisitOperator<'a>> VisitOperator<'a> for &'b mut V { +impl<'a, 'b, V: VisitOperator<'a> + ?Sized> VisitOperator<'a> for &'b mut V { type Output = V::Output; fn visit_operator(&mut self, op: &Operator<'a>) -> Self::Output { V::visit_operator(*self, op) } for_each_operator!(define_visit_operator_delegate); } + +impl<'a, 'b, V: VisitOperator<'a> + ?Sized> VisitOperator<'a> for Box { + type Output = V::Output; + fn visit_operator(&mut self, op: &Operator<'a>) -> Self::Output { + V::visit_operator(&mut *self, op) + } + for_each_operator!(define_visit_operator_delegate); +}