diff options
Diffstat (limited to 'src/offset_of.rs')
-rw-r--r-- | src/offset_of.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/offset_of.rs b/src/offset_of.rs index a363d30..8596e45 100644 --- a/src/offset_of.rs +++ b/src/offset_of.rs @@ -72,8 +72,7 @@ macro_rules! _memoffset_offset_from_unsafe { /// /// ## Examples /// ``` -/// #[macro_use] -/// extern crate memoffset; +/// use memoffset::offset_of; /// /// #[repr(C, packed)] /// struct Foo { @@ -103,8 +102,7 @@ macro_rules! offset_of { /// /// ## Examples /// ``` -/// #[macro_use] -/// extern crate memoffset; +/// use memoffset::offset_of_tuple; /// /// fn main() { /// assert!(offset_of_tuple!((u8, u32), 1) >= 0, "Tuples do not have a defined layout"); @@ -255,6 +253,18 @@ mod tests { #[cfg(feature = "unstable_const")] #[test] + fn const_offset_interior_mutable() { + #[repr(C)] + struct Foo { + a: u32, + b: core::cell::Cell<u32>, + } + + assert_eq!([0; offset_of!(Foo, b)].len(), 4); + } + + #[cfg(feature = "unstable_const")] + #[test] fn const_fn_offset() { const fn test_fn() -> usize { #[repr(C)] |