mirror of
https://github.com/serde-rs/json.git
synced 2026-03-10 07:49:11 +00:00
Provide optimized collect_str methods for Value serializer
This commit is contained in:
parent
f59b637295
commit
da0a39fff7
@ -267,6 +267,13 @@ impl serde::Serializer for Serializer {
|
||||
map: Map::new(),
|
||||
})
|
||||
}
|
||||
|
||||
fn collect_str<T: ?Sized>(self, value: &T) -> Result<Value>
|
||||
where
|
||||
T: Display,
|
||||
{
|
||||
Ok(Value::String(value.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SerializeVec {
|
||||
@ -593,6 +600,13 @@ impl serde::Serializer for MapKeySerializer {
|
||||
) -> Result<Self::SerializeStructVariant> {
|
||||
Err(key_must_be_a_string())
|
||||
}
|
||||
|
||||
fn collect_str<T: ?Sized>(self, value: &T) -> Result<String>
|
||||
where
|
||||
T: Display,
|
||||
{
|
||||
Ok(value.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl serde::ser::SerializeStruct for SerializeMap {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user