RFC 2349 proposing a new set of APIs to deal with types that cannot be safely moved around - especially generators and async functions. You can read more details of the design in the RFC. This thread is a sidebar to discuss the names of these types.
The names proposed in the RFC were arrived at ‘evolutionarily’ as several different previous APIs converged into the present one. So they’re not necessarily very good.
The relationship between the three items (review of the RFC)
The trait Move is an auto trait. Types which don’t implement Move restrict the functionality of Anchor and Pin. They are designed to guarantee that if a type is not Move, once its in an anchor or a pin it will never move again.
Anchor<T> and Pin<'a, T> are a lot like Box<T> and &'a mut T respectively - in fact, they each are just wrappers around those types. The difference between anchor/pin and box/mut ref is that when the type does not implement Move, Anchor and Pin do not provide APIs that allow you to move that type out of them.
Name length
Its important to consider how these types will be used, and how the length of their name impacts their ergonomics. All of these names want to be short
Anchor and Pin will both likely be used as method receivers. Being short makes this easier (especially Pin, because of its lifetime).
fn foo(self: Anchor<Self>)
fn bar(self: Pin<'_, Self>)
Move may also appear in APIs as a bound where it is not extremely relevant, similar to Send and Sync. Being short helps make it easier for readers to focus on the more relevant parts of the bound:
where T: MyRelevantTrait<U> + Move + Send
// vs
where T: MyRelevantTrait<U> + IrrelevantMove + Send
Problems with the current names
-
Mixed metaphors: One thing that’s not great about the current name is that its got a bit of mixed metaphors - we have both anchors and pins.
-
Move is very broad:
Move sounds like a very general trait, but it only really controls the behavior of Anchor/Pin.
-
No indication of relationship: Anchor is to Box as Pin is to &mut, but the names don’t make this clear at all.
A proposal to get us started
Here’s an alternative set of names which is still pretty short, but resolves the problems with the current names:
-
Pin<'a, T> => Pin<'a, T> (no change)
-
Anchor<T> => PinBox<T>
-
Move => MovePinned