Skip to content

Commit f4e6440

Browse files
committed
Improved code
1 parent ad20528 commit f4e6440

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/bit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl Bit {
1919
let len = data.len();
2020
let mut bytes = vec![0; (len + 7) / 8];
2121
for (i, v) in data.iter().enumerate() {
22-
bytes[i / 8] |= (*v as u8) << (7 - (i % 8));
22+
bytes[i / 8] |= u8::from(*v) << (7 - (i % 8));
2323
}
2424
Bit { len, data: bytes }
2525
}

src/halfvec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl HalfVector {
3939
pub(crate) fn from_sql(
4040
buf: &[u8],
4141
) -> Result<HalfVector, Box<dyn std::error::Error + Sync + Send>> {
42-
let dim = u16::from_be_bytes(buf[0..2].try_into()?) as usize;
42+
let dim = u16::from_be_bytes(buf[0..2].try_into()?).into();
4343
let unused = u16::from_be_bytes(buf[2..4].try_into()?);
4444
if unused != 0 {
4545
return Err("expected unused to be 0".into());

src/vector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl Vector {
4242

4343
#[cfg(any(feature = "postgres", feature = "sqlx", feature = "diesel"))]
4444
pub(crate) fn from_sql(buf: &[u8]) -> Result<Vector, Box<dyn std::error::Error + Sync + Send>> {
45-
let dim = u16::from_be_bytes(buf[0..2].try_into()?) as usize;
45+
let dim = u16::from_be_bytes(buf[0..2].try_into()?).into();
4646
let unused = u16::from_be_bytes(buf[2..4].try_into()?);
4747
if unused != 0 {
4848
return Err("expected unused to be 0".into());

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy