[rust-dev] sizeof type

Niko Matsakis niko at alum.mit.edu
Tue Apr 10 06:27:20 PDT 2012


Hello,

The `sys` module in core has `size_of()` and `align_of()` functions.  So 
you could write `sys::size_of::<test_type>()`, for example.


Niko

On 4/10/12 4:07 AM, Alexander Stavonin wrote:
> Hi,
>
> I have a type which will be bind to appropriate C structure:
>
> type test_type = {
>      val1 : i16;
>      val2 : i32;
> }
>
> How could I get size of the test_type? How could I provide an information about alignment of the test_type?
>
> Regards,
> Alexander.
> _______________________________________________
> Rust-dev mailing list
> Rust-dev at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev



More information about the Rust-dev mailing list