I'm creating a data structure that includes Boxes and Vecs and Vecs of Boxes, and I find myself between two choices:
- Have the top-level data structure own the
Allocator and have each nested structure use the free &A implementation
- Require the
Allocator to be Clone and just clone it at each usage point
Based on this section in the docs:
cloning or moving the allocator must not invalidate memory blocks returned from this allocator. A cloned allocator must behave like the same allocator
it seems like the expected pattern is 2, and that therefore most allocators will be Clone. Is that correct?
I'm creating a data structure that includes
Boxes andVecs andVecs ofBoxes, and I find myself between two choices:Allocatorand have each nested structure use the free&AimplementationAllocatorto beCloneand justcloneit at each usage pointBased on this section in the docs:
it seems like the expected pattern is 2, and that therefore most allocators will be
Clone. Is that correct?