Skip to content

Commit

Permalink
Replace char::to_string with encode_utf8
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Sep 4, 2024
1 parent 4921906 commit 3f4e30a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

use crate::error::{Error, ErrorCode, Result};
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 core::fmt::{self, Display};
use core::num::FpCategory;
Expand Down Expand Up @@ -1057,7 +1059,7 @@ where
}

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<()> {
Expand Down

0 comments on commit 3f4e30a

Please sign in to comment.