You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-08-09 16:58:19 +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:
@ -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",
|
type_name::<T>(), size_of::<T>(), align_of::<T>());
|
||||||
stringify!($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>();
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user