it would be nice to not have to move data on the stack to insert into the slab, esp. since the intention is to provide preallocated storage. Currently, we use Option<T> for our slots, and move an item into the Option (making it Some) when inserting. This means copying data onto the stack, which is a shame if the slab is being used to store large objects:
We might want to consider using MaybeUninit instead, so we can have an API like
since this would play nicer with loom's CausalCell::with, and because users wouldn't have to unpack the tuple.
This has the disadvantage of forcing users to deal with MaybeUninit, which would currently require unsafe code and is somewhat significantly less ergonomic. However, we can continue providing the current API as well, implemented on top of a MaybeUninit-based API.
it would be nice to not have to move data on the stack to insert into the slab, esp. since the intention is to provide preallocated storage. Currently, we use
Option<T>
for our slots, and move an item into theOption
(making itSome
) when inserting. This means copying data onto the stack, which is a shame if the slab is being used to store large objects:We might want to consider using
MaybeUninit
instead, so we can have an API likewith the
MaybeUninit
reference being used as an out-param.It might be better for this to be more like
since this would play nicer with
loom
'sCausalCell::with
, and because users wouldn't have to unpack the tuple.This has the disadvantage of forcing users to deal with
MaybeUninit
, which would currently require unsafe code and is somewhat significantly less ergonomic. However, we can continue providing the current API as well, implemented on top of aMaybeUninit
-based API.