# Pre-RFC: placement box with Placer trait

**URL:** <https://internals.rust-lang.org/t/pre-rfc-placement-box-with-placer-trait/729>\
**Category:** ideas (deprecated)\
**Created:** [October 29, 2014, 12:36am UTC](https://internals.rust-lang.org/t/pre-rfc-placement-box-with-placer-trait/729 "2014-10-29T00:36:07Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![nikomatsakis](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/nikomatsakis/32/5410_2.png) [@nikomatsakis](https://internals.rust-lang.org/u/nikomatsakis)\
**Post date:** [October 29, 2014, 10:45am UTC](https://internals.rust-lang.org/t/pre-rfc-placement-box-with-placer-trait/729/6 "2014-10-29T10:45:56Z")

</div>

Actually, re-reading Gankro’s comment and the RFC, I got to thinking about the mutability of varous things here.

1. I suspect that the `pointer` method on `PlacementAgent` ought to take `&mut self`.
2. I don’t see why it matters or should be expected for `"pointer"` to be cheap in particular. We expect to call it once, after all.
3. The use of `&self` on the `Placer` trait isn’t ideal. Perhaps removing the `Placer` trait and having just the `PlacementAgent` would be the right thing after all.

It would be nice if you could write all of the following:

1. `box(in RC) foo`
2. `box(in vec.emplace_back()) foo`
3. `box(in arena) foo`

(I’m not sure yet which syntax I prefer, I thought i’d experiment)

But I’m not sure we can have all three. But maybe that’s just fine.

The first one seems to work most anyway we do it. RC is a global constant, so it is actually an rvalue at the moment, but even if we eventually allowed global constants to be lvalues, then it could implement `Copy` as it has no state, and hence it could potentially serve as the placement agent (though the expansion would have to carry the data type `T` externally).

The second one really prefers no placer at all.

The third one wants the current design.

Finally, looking forward to when we have customizable memory allocators, we probably want a fourth use case, which is the ability to put a box in a specific allocator. The protocol can accommodate this fine, but it’s another instance where, similar to emplace\_back, you don’t really need the `Placer` trait. I imagine it would look something like:

```
box(in Rc(alloc)) foo

```

Anyway, I’ll try to sketch out what I mean in more detail, but atm I am leaning towards saying we can remove the `Placer` trait after all (I know I poopoo’d the idea last time you raised it, sorry).

---

_[View the full topic](https://internals.rust-lang.org/t/pre-rfc-placement-box-with-placer-trait/729)._
