W3cubDocs

/Rust

Function std::mem::size_of

pub fn size_of<T>() -> usize

Returns the size of a type in bytes.

More specifically, this is the offset in bytes between successive items of the same type, including alignment padding.

Examples

use std::mem;

assert_eq!(4, mem::size_of::<i32>());

© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/mem/fn.size_of.html