Merge pull request #1764 from serde-rs/collect

Simplify default Serializer::collect_str implementation
This commit is contained in:
David Tolnay 2020-03-27 23:10:06 -07:00 committed by GitHub
commit 2a9971a69d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1359,10 +1359,7 @@ pub trait Serializer: Sized {
where
T: Display,
{
use lib::fmt::Write;
let mut string = String::new();
write!(string, "{}", value).unwrap();
self.serialize_str(&string)
self.serialize_str(&value.to_string())
}
/// Serialize a string produced by an implementation of `Display`.