deepsize icon indicating copy to clipboard operation
deepsize copied to clipboard

Examples of using Context

Open dtolnay opened this issue 6 years ago • 1 comments

Currently none of the example code or documentation shows how to use Context. I would expect to see usage examples on this page:

https://docs.rs/deepsize/0.1.1/deepsize/struct.Context.html

@Aeledfyr

dtolnay avatar Feb 17 '19 21:02 dtolnay

The documentation also currently suggests that Context should become a private type before stabilization. But it can be quite useful to allow for re-using a Context across multiple calls.

For example: I would like to make multiple deep_size_of calls for known roots of an object graph (where objects are likely to contain Arcs sharing content), without those individual deep_size_of calls double-counting shared structure. The end result is still an accurate total, even though it might "blame" some of the deep size to one root rather than another based on the call order.

stuhood avatar Feb 27 '22 01:02 stuhood