#[derive(TypeSize)]
{
// Attributes available to this derive:
#[typesize]
}
Expand description
Implements TypeSize automatically for a struct or enum.
Use #[typesize(skip)] on a field to assume it does not manage any external memory.
Use #[typesize(with = path::to::fn)] on a field to specify a custom extra_size for that field.
The function accepts a reference to the type of the field.
This will avoid requiring TypeSize to be implemented for this field, however may lead to undercounted results if the assumption does not hold.
§Struct Mode
TypeSize::extra_size will be calculated by adding up the extra_size of all fields.
§Enum Mode
TypeSize::extra_size will be calculated by adding up the extra_size of all of the fields of the active enum variant.
§Union Mode
Unions are unsupported as there is no safe way to calculate the extra_size, implement typesize::TypeSize manually.