4 releases (2 stable)
Uses old Rust 2015
2.0.0 | Jul 22, 2019 |
---|---|
1.0.0 | Oct 11, 2018 |
0.1.0 | Oct 11, 2018 |
0.0.1 | Aug 5, 2018 |
#19 in #corpus
11KB
170 lines
/ Build status: (Linux & MacOS) (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.
Dependencies
~2MB
~49K SLoC