1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-08-11 09:21:40 +02:00

Remove unneeded macro from Enum Sizes slide (#1015)

* Remove unneeded macro from Enum Sizes slide

* Update src/enums/sizes.md

---------

Co-authored-by: Martin Geisler <martin@geisler.net>
This commit is contained in:
Dominik Maier
2023-07-21 16:23:30 +02:00
committed by GitHub
parent e2038b4897
commit 6e367132ad

View File

@@ -3,13 +3,12 @@
Rust enums are packed tightly, taking constraints due to alignment into account: Rust enums are packed tightly, taking constraints due to alignment into account:
```rust,editable ```rust,editable
use std::any::type_name;
use std::mem::{align_of, size_of}; use std::mem::{align_of, size_of};
macro_rules! dbg_size { fn dbg_size<T>() {
($t:ty) => {
println!("{}: size {} bytes, align: {} bytes", println!("{}: size {} bytes, align: {} bytes",
stringify!($t), size_of::<$t>(), align_of::<$t>()); type_name::<T>(), size_of::<T>(), align_of::<T>());
};
} }
enum Foo { enum Foo {
@@ -18,7 +17,7 @@ enum Foo {
} }
fn main() { fn main() {
dbg_size!(Foo); dbg_size::<Foo>();
} }
``` ```