#fork #corpus #servo #codebase #search #io #part

macro graphannis-malloc_size_of_derive

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

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

#14 in #corpus

Download history 22/week @ 2024-03-13 6/week @ 2024-03-20 18/week @ 2024-03-27 20/week @ 2024-04-03 2/week @ 2024-04-17 19/week @ 2024-04-24 1/week @ 2024-05-01 2/week @ 2024-05-22 4/week @ 2024-05-29 25/week @ 2024-06-05 45/week @ 2024-06-12 1/week @ 2024-06-19

73 downloads per month

Apache-2.0

11KB
170 lines

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.

Dependencies

~2MB
~47K SLoC