graphannis-malloc_size_of_derive 2.0.0

This is a fork of the `malloc_size_of_derive` crate, which is part of the Servo codebase, to make it available to the graphANNIS corpus search library as dependency.
Documentation

Documentation link / Build status: Build Status Linux & MacOS (Linux & MacOS) Build status Windows (Windows)

graphannis-malloc_size_of_derive

This is a fork of the malloc_size_of_derive crate, which is part of the Servo codebase but not published on crates.io yet. The intention of this fork is to make the functionality of the original crate available to the graphANNIS corpus search library, which is published on crates.io.

with_malloc_size_of_func field attribute

In comparision to the original crate, a new with_malloc_size_of_func field attribute for structs was added to allow overriding the default calculation with a custom function. E.g. you can write

fn custom_func(obj: &Bar, ops: &mut MallocSizeOfOps) -> usize {
    // do some custom calculations
}

#[derive(MallocSizeOf)]
struct Foo {
    bar: Baz,
    #[with_malloc_size_of_func = "custom_func"]
    baz: Bar,
}

This mechanism allows useful if MallocSizeOf can be derived normally for some fields but not for others. Instead of implementing MallocSizeOf manually for the whole struct (where it is easy to forget some fields), only the missing information for the specific fields need to be provided.