Pgsql cube type compile fail (#3459)

* fails to compile as size_of is not found in scope

* keep scoping consistent with other type modules

* fmt fixes

---------

Co-authored-by: kdesjard <kristian.desjardins@nrcan-rncan.gc.ca>
This commit is contained in:
kdesjard 2024-08-26 17:15:48 -04:00 committed by GitHub
parent 8a17bef7d7
commit 371cf4a0cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View file

@ -5,6 +5,7 @@ use crate::types::Type;
use crate::{PgArgumentBuffer, PgHasArrayType, PgTypeInfo, PgValueFormat, PgValueRef, Postgres};
use sqlx_core::bytes::Buf;
use sqlx_core::Error;
use std::mem;
use std::str::FromStr;
const BYTE_WIDTH: usize = 8;
@ -304,7 +305,7 @@ fn remove_parentheses(s: &str) -> String {
}
impl Header {
const PACKED_WIDTH: usize = size_of::<u32>();
const PACKED_WIDTH: usize = mem::size_of::<u32>();
fn encoded_size(&self) -> usize {
Self::PACKED_WIDTH + self.data_size()

View file

@ -1,6 +1,6 @@
use std::{
collections::{btree_map, BTreeMap},
mem::size_of,
mem,
ops::{Deref, DerefMut},
str,
};
@ -214,10 +214,10 @@ impl Encode<'_, Postgres> for PgHstore {
}
fn read_length(buf: &mut &[u8]) -> Result<i32, String> {
if buf.len() < size_of::<i32>() {
if buf.len() < mem::size_of::<i32>() {
return Err(format!(
"expected {} bytes, got {}",
size_of::<i32>(),
mem::size_of::<i32>(),
buf.len()
));
}