Introduction
In this lab, we learn about literals in Rust and how to specify their types by adding a suffix. Suffixed literals have their types known at initialization, while unsuffixed literals' types depend on how they are used. The size_of_val
function is used to determine the size of a variable in bytes, and it is called with its full path, std::mem::size_of_val
. The size_of_val
function is defined in the mem
module, which is in turn defined in the std
crate.
Note: If the lab does not specify a file name, you can use any file name you want. For example, you can use
main.rs
, compile and run it withrustc main.rs && ./main
.