Skip to content

Commit 129e7c4

Browse files
Slightly simplified zerocopy usage in tests (image-rs#62)
1 parent 52ab1dc commit 129e7c4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::{
99
io::Seek,
1010
path::{Path, PathBuf},
1111
};
12-
use zerocopy::{FromBytes, Immutable, IntoBytes, Ref};
12+
use zerocopy::{FromBytes, Immutable, IntoBytes};
1313
use Precision::*;
1414

1515
pub fn create_rng() -> impl rand::Rng {
@@ -47,10 +47,10 @@ pub fn hash_hex_f32(data: &[f32]) -> String {
4747
pub trait Castable: FromBytes + IntoBytes + Immutable {}
4848
impl<T: FromBytes + IntoBytes + Immutable> Castable for T {}
4949
pub fn from_bytes<T: Castable>(bytes: &[u8]) -> Option<&[T]> {
50-
Ref::from_bytes(bytes).ok().map(Ref::into_ref)
50+
FromBytes::ref_from_bytes(bytes).ok()
5151
}
5252
pub fn from_bytes_mut<T: Castable>(bytes: &mut [u8]) -> Option<&mut [T]> {
53-
Ref::from_bytes(bytes).ok().map(Ref::into_mut)
53+
FromBytes::mut_from_bytes(bytes).ok()
5454
}
5555
pub fn as_bytes_mut<T: Castable>(buffer: &mut [T]) -> &mut [u8] {
5656
buffer.as_mut_bytes()

0 commit comments

Comments
 (0)