You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-08-09 08:48:05 +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,editable
|
||||
use std::any::type_name;
|
||||
use std::mem::{align_of, size_of};
|
||||
|
||||
macro_rules! dbg_size {
|
||||
($t:ty) => {
|
||||
println!("{}: size {} bytes, align: {} bytes",
|
||||
stringify!($t), size_of::<$t>(), align_of::<$t>());
|
||||
};
|
||||
fn dbg_size<T>() {
|
||||
println!("{}: size {} bytes, align: {} bytes",
|
||||
type_name::<T>(), size_of::<T>(), align_of::<T>());
|
||||
}
|
||||
|
||||
enum Foo {
|
||||
@ -18,7 +17,7 @@ enum Foo {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
dbg_size!(Foo);
|
||||
dbg_size::<Foo>();
|
||||
}
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user