Closed rfael closed 3 years ago
serialize_bytes can push to output JSON raw bytes now. I now it can produce JSON with invalid data so it should be used with caution. I added this because I need a way to serialize f32 with fixed precision. Example:
serialize_bytes
pub struct SimpleDecimal(f32); impl Serialize for SimpleDecimal { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { let mut aux: String<U48> = String::new(); write!(aux, "{:.2}", self.0).unwrap(); serializer.serialize_bytes(&aux.as_bytes()) } }
@eldruin Changelog updated.
serialize_bytes
can push to output JSON raw bytes now. I now it can produce JSON with invalid data so it should be used with caution. I added this because I need a way to serialize f32 with fixed precision. Example: