diff --git a/sqlx-postgres-protocol/src/decode.rs b/sqlx-postgres-protocol/src/decode.rs index c1a00ffbc..865fa97af 100644 --- a/sqlx-postgres-protocol/src/decode.rs +++ b/sqlx-postgres-protocol/src/decode.rs @@ -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) }