Skip to content

Commit

Permalink
Pgsql cube type compile fail (launchbadge#3459)
Browse files Browse the repository at this point in the history
* fails to compile as size_of is not found in scope

* keep scoping consistent with other type modules

* fmt fixes

---------

Co-authored-by: kdesjard <[email protected]>
  • Loading branch information
2 people authored and jrasanen committed Oct 14, 2024
1 parent 7ca3565 commit 1ee7afa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion sqlx-postgres/src/types/cube.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions sqlx-postgres/src/types/hstore.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
collections::{btree_map, BTreeMap},
mem::size_of,
mem,
ops::{Deref, DerefMut},
str,
};
Expand Down Expand Up @@ -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()
));
}
Expand Down

0 comments on commit 1ee7afa

Please sign in to comment.