Implement Serialize for core::fmt::Arguments

This commit is contained in:
David Tolnay 2018-06-26 23:29:44 -07:00
parent d827b101d9
commit 84e384196d
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 14 additions and 0 deletions

View File

@ -69,6 +69,15 @@ impl Serialize for String {
} }
} }
impl<'a> Serialize for fmt::Arguments<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.collect_str(self)
}
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#[cfg(feature = "std")] #[cfg(feature = "std")]

View File

@ -462,6 +462,11 @@ declare_tests! {
Token::SeqEnd, Token::SeqEnd,
], ],
} }
test_fmt_arguments {
format_args!("{}{}", 1, 'a') => &[
Token::Str("1a"),
],
}
} }
declare_tests! { declare_tests! {