From 84e384196d66fddf49ed93387ccf8f04d95af11c Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 26 Jun 2018 23:29:44 -0700 Subject: [PATCH] Implement Serialize for core::fmt::Arguments --- serde/src/ser/impls.rs | 9 +++++++++ test_suite/tests/test_ser.rs | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/serde/src/ser/impls.rs b/serde/src/ser/impls.rs index 0b21e541..cb273982 100644 --- a/serde/src/ser/impls.rs +++ b/serde/src/ser/impls.rs @@ -69,6 +69,15 @@ impl Serialize for String { } } +impl<'a> Serialize for fmt::Arguments<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.collect_str(self) + } +} + //////////////////////////////////////////////////////////////////////////////// #[cfg(feature = "std")] diff --git a/test_suite/tests/test_ser.rs b/test_suite/tests/test_ser.rs index cd4ce6bf..eff19069 100644 --- a/test_suite/tests/test_ser.rs +++ b/test_suite/tests/test_ser.rs @@ -462,6 +462,11 @@ declare_tests! { Token::SeqEnd, ], } + test_fmt_arguments { + format_args!("{}{}", 1, 'a') => &[ + Token::Str("1a"), + ], + } } declare_tests! {