mirror of
https://github.com/serde-rs/serde.git
synced 2025-10-02 15:25:38 +00:00
Change comment to // Safety: ...
This changes a comment to be explicit on how it's safe we can avoid validating UTF-8.
This commit is contained in:
parent
15ec95a98d
commit
1050f6b808
@ -736,8 +736,9 @@ impl Serialize for net::Ipv4Addr {
|
||||
// Skip over delimiters that we initialized buf with
|
||||
written += format_u8(*oct, &mut buf[written + 1..]) + 1;
|
||||
}
|
||||
// We've only written ASCII bytes to the buffer, so it is valid UTF-8
|
||||
serializer.serialize_str(unsafe { str::from_utf8_unchecked(&buf[..written]) })
|
||||
// Safety: We've only written ASCII bytes to the buffer, so it is valid UTF-8
|
||||
let buf = unsafe { str::from_utf8_unchecked(&buf[..written]) };
|
||||
serializer.serialize_str(buf)
|
||||
} else {
|
||||
self.octets().serialize(serializer)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user