Closed shlevy closed 2 years ago
hashbrown
also requires allocators to be Clone
. In practice I would expect the vast majority of allocators to be Clone
.
Note that you can always create a Clone
allocator by using &T
. So the Clone
bound is strictly more general, as it also allows non-&T
allocators.
In general, yes.
Allocators should generally be a cheap-to-copy handle to an upstream memory resource.
Seems like there's consensus, thanks!
I'm creating a data structure that includes
Box
es andVec
s andVec
s ofBox
es, and I find myself between two choices:Allocator
and have each nested structure use the free&A
implementationAllocator
to beClone
and justclone
it 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?