use get_size2::GetSize; #[derive(GetSize)] struct TestStructGenerics { value1: A, value2: B, } #[derive(GetSize)] enum TestEnumGenerics { Variant1(A), Variant2(B), } fn main() { let test: TestStructGenerics = TestStructGenerics { value1: "Hello".into(), value2: 123, }; assert_eq!(test.get_heap_size(), 5); let test = String::from("Hello"); let test: TestEnumGenerics = TestEnumGenerics::Variant1(test); assert_eq!(test.get_heap_size(), 5); let test: TestEnumGenerics = TestEnumGenerics::Variant2(100); assert_eq!(test.get_heap_size(), 0); }