You cannot define size_of_val in terms of size_of.
fn main() {
let f: &str = "size_of_val";
// There is no such thing as size of `str` because the size is
// not necessarily known at compile time.
println!("{}", std::mem::size_of::<str>());
// This looks at the size of the specific `str` value at runtime.
// In this case 11.
println!("{}", std::mem::size_of_val::<str>(f));
}