Skip to content

size_of cannot be called outside of a function #6320

Closed
@dymk

Description

@dymk

I realize this isn't an issue that can be fixed by changing the definition of sys::size_of, however it seems like Rust (like any systems programming language) should have a mechanism for determining the size of a type.

a-la:

pub type MyType = u32;
// Couldn't really be done like this, but you get the idea
pub static MyTypeBits = sys::sizeof::<MyType>() * 8; 

Could be implemented with a macro? Something like size_of!(MyType).

Metadata

Metadata

Assignees

No one assigned

    Labels

    P-lowLow priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions