Skip to content

Commit ccae97b

Browse files
authored
Avoid dependency on platform-specific machine word size (#1096)
Signed-off-by: Alexander Rodin <[email protected]>
1 parent 25813de commit ccae97b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/buffers/disk.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use snafu::{ResultExt, Snafu};
1818
use std::collections::VecDeque;
1919
use std::convert::TryInto;
2020
use std::io;
21+
use std::mem::size_of;
2122
use std::path::{Path, PathBuf};
2223
use std::sync::{
2324
atomic::{AtomicUsize, Ordering},
@@ -47,7 +48,7 @@ struct Key(usize);
4748

4849
impl db_key::Key for Key {
4950
fn from_u8(key: &[u8]) -> Self {
50-
let bytes: [u8; 8] = key.try_into().expect("Key should be the right size");
51+
let bytes: [u8; size_of::<usize>()] = key.try_into().expect("Key should be the right size");
5152

5253
Self(usize::from_be_bytes(bytes))
5354
}

0 commit comments

Comments
 (0)