Assume Postgres isn't lying (use UTF-8 unchecked)

This commit is contained in:
Ryan Leckey
2019-06-28 00:30:12 -07:00
parent 631f91ea16
commit 903f674257

View File

@@ -12,7 +12,7 @@ pub trait Decode {
pub(crate) fn get_str(src: &[u8]) -> io::Result<&str> {
let end = memchr(b'\0', &src).ok_or(io::ErrorKind::UnexpectedEof)?;
let buf = &src[..end];
let s = str::from_utf8(buf).map_err(|_| io::ErrorKind::InvalidData)?;
let s = unsafe { str::from_utf8_unchecked(buf) };
Ok(s)
}