Skip to content

Commit

Permalink
Merge pull request #61 from mina86/c
Browse files Browse the repository at this point in the history
ser: don’t unnecessarily allocate a String when serialising a character
  • Loading branch information
chipshort authored Aug 4, 2023
2 parents f3b76de + 1411571 commit a34f5f2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ser/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ impl<'a> ser::Serializer for MapKeySerializer<'a> {
}

fn serialize_char(self, value: char) -> Result<()> {
self.ser.serialize_str(&value.to_string())
let mut buf = [0u8; 4];
self.ser.serialize_str(value.encode_utf8(&mut buf))
}

fn serialize_bytes(self, _value: &[u8]) -> Result<()> {
Expand Down

0 comments on commit a34f5f2

Please sign in to comment.