Skip to content

Commit 381a29b

Browse files
committed
add a helper module with a project_ref function
1 parent dc39a6e commit 381a29b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/helper.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use core::ptr;
2+
3+
use crate::marker::Field;
4+
5+
pub fn project_ref<F: Field>(r: &F::Base) -> &F::Type
6+
where
7+
F::Type: Sized,
8+
{
9+
unsafe { &*ptr::from_ref(r).byte_add(F::OFFSET).cast() }
10+
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
#![warn(unsafe_op_in_unsafe_fn)]
44

55
pub mod compat;
6+
pub mod helper;
67
pub mod marker;
78
pub mod ops;

0 commit comments

Comments
 (0)