Skip to content

Remove usage of memoffset::offset_of#39

Open
syberant wants to merge 1 commit into
ColinFinck:masterfrom
syberant:master
Open

Remove usage of memoffset::offset_of#39
syberant wants to merge 1 commit into
ColinFinck:masterfrom
syberant:master

Conversation

@syberant

@syberant syberant commented Jul 7, 2026

Copy link
Copy Markdown

Hi, I may or may not have used your crate but I'd like to say a quick thank you for it anyway!
I'm going down the list of reverse dependencies on memoffset.

This PR originally aimed to remove the memoffset crate from your dependencies.
core::mem::offset_of was stabilised in rustc 1.77 which I believe is at or below your MSRV.

The memoffset crate 0.9.1 says that

If you're using a rustc version greater or equal to 1.77,
this crate's offset_of!() macro simply forwards to core::mem::offset_of!().


A singular use of memoffset::span_of! prevents removing the dependency, if you're willing to hardcode it we could.

    pub(crate) fn signature(&self) -> [u8; 4] {
        self.data[span_of!(RecordHeader, signature)]
            .try_into()
            .unwrap()
    }

where

#[repr(C, packed)]
pub(crate) struct RecordHeader {
    signature: [u8; 4],
    update_sequence_offset: u16,
    update_sequence_count: u16,
    logfile_sequence_number: u64,
}

`memoffset::offset_of!` was stabilised as `core::mem::offset_of!` in
rust 1.77
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant