Skip to content

size_of cannot be called outside of a function #6320

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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