Replace char::to_string with encode_utf8

This commit is contained in:
David Tolnay 2024-09-04 15:21:26 -07:00
parent 4921906b1d
commit 3f4e30a584
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -2,7 +2,9 @@
use crate::error::{Error, ErrorCode, Result}; use crate::error::{Error, ErrorCode, Result};
use crate::io; use crate::io;
use alloc::string::{String, ToString}; use alloc::string::String;
#[cfg(feature = "raw_value")]
use alloc::string::ToString;
use alloc::vec::Vec; use alloc::vec::Vec;
use core::fmt::{self, Display}; use core::fmt::{self, Display};
use core::num::FpCategory; use core::num::FpCategory;
@ -1057,7 +1059,7 @@ where
} }
fn serialize_char(self, value: char) -> Result<()> { fn serialize_char(self, value: char) -> Result<()> {
self.ser.serialize_str(&value.to_string()) self.ser.serialize_str(value.encode_utf8(&mut [0u8; 4]))
} }
fn serialize_bytes(self, _value: &[u8]) -> Result<()> { fn serialize_bytes(self, _value: &[u8]) -> Result<()> {