pub fn size_of_val<T>(val: T) -> u64 
Expand description

Returns the size of the type of a value in bytes.

Arguments

  • val - The value to get the size of.

Returns

  • [u64] - The size of the type of val in bytes.

Examples

use std::intrinsics::size_of_val;

fn foo() {
    let a = 1;
    assert(size_of_val(a) == 8);
}
use std::intrinsics::size_of_val;

pub struct Foo {
    a: u64,
    b: u64,
}

fn foo() {
    let a = Foo { a: 1, b: 2 };
    assert(size_of_val(a) == 16);
}