graphannis-malloc_size_of_derive

Crates.iographannis-malloc_size_of_derive
lib.rsgraphannis-malloc_size_of_derive
version2.0.0
sourcesrc
created_at2018-08-05 19:04:17.079672
updated_at2019-07-22 10:13:00.736905
descriptionThis 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.
homepage
repositoryhttps://github.com/corpus-tools/graphannis-malloc_size_of_derive
max_upload_size
id77657
size23,843
Thomas Krause (thomaskrause)

documentation

README

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.

Commit count: 20

cargo fmt