From 23abf75725f4951c42039a8b6931af6d4408edd3 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Mon, 21 Nov 2022 21:49:39 -0800 Subject: [PATCH] Add blanket ToXml implementation for &impl ToXml --- instant-xml/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/instant-xml/src/lib.rs b/instant-xml/src/lib.rs index 63dd9b4..ba57ea4 100644 --- a/instant-xml/src/lib.rs +++ b/instant-xml/src/lib.rs @@ -22,6 +22,17 @@ pub trait ToXml { const KIND: Kind; } +impl<'a, T: ToXml + ?Sized> ToXml for &'a T { + fn serialize( + &self, + serializer: &mut Serializer, + ) -> Result<(), Error> { + (*self).serialize(serializer) + } + + const KIND: Kind = T::KIND; +} + pub trait FromXml<'xml>: Sized { fn deserialize<'cx>(deserializer: &'cx mut Deserializer<'cx, 'xml>) -> Result;