Skip to content

question: why is Buf32 #[repr(packed)] #29

Closed
@kontrafiktion

Description

@kontrafiktion

If I understand https://doc.rust-lang.org/nomicon/other-reprs.html#reprpacked correctly,
#[repr(packed)] forces byte alignment. And it sounds like this may be problematic:

most architectures strongly prefer values to be aligned.

I very new to Rust (and system level programming), but this sounds scary to me.

Could you explain, why the Buf32 should be packed?

#[repr(packed)]
pub struct Buf32<H> {
    pub ptr: *mut H,
    pub len: u32,
    pub cap: u32,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions