Description
This came up in the discussion of #1228, but it's mostly independent from the syntax change proposed there. Currently creating a Place
for "placement box" will consume the value that produces the place (the one that's written out in the placement expression, i.e. PLACE
in box (PLACE) EXPR
). This hasn't been an issue so far because the only implementation (in std and, as far as I can tell, on GitHub overall) in ExchangeHeapSingleton
which is Copy
. That type (and its public name, boxed::HEAP
) is hanging by a thread though, box thing
is widely preferred to in (HEAP) thing
or in HEAP { thing }
or HEAP <- thing
or any variant of that.
Some hypothetical types that would implement Placer
in the future (such as &Arena
and the results of map.entry(k)
, vec.back()
) would likely be Copy
or inherently "one-off", but other possible uses of placement box would be ruled out by taking self
. Examples raised in #1228 are vec <- thing;
(instead of vec.push(thing)
), set <- thing;
and (disclaimer: my example and pet interest) allocators that can't be behind a &
reference.
I am personally becoming more convinced that it should be
&mut self
. I spent a while last night looking through my notes to see why I had pickedself
but did not find a motivating example.