Crates.io | graphannis-malloc_size_of_derive |
lib.rs | graphannis-malloc_size_of_derive |
version | 2.0.0 |
source | src |
created_at | 2018-08-05 19:04:17.079672 |
updated_at | 2019-07-22 10:13:00.736905 |
description | 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. |
homepage | |
repository | https://github.com/corpus-tools/graphannis-malloc_size_of_derive |
max_upload_size | |
id | 77657 |
size | 23,843 |
/ Build status: (Linux & MacOS) (Windows)
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 attributeIn 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.