# Why am I not allowed to move arg in Pin::map\_unchecked?

**URL:** <https://internals.rust-lang.org/t/why-am-i-not-allowed-to-move-arg-in-pin-map-unchecked/19664>\
**Category:** Uncategorized\
**Created:** [October 7, 2023, 9:08pm UTC](https://internals.rust-lang.org/t/why-am-i-not-allowed-to-move-arg-in-pin-map-unchecked/19664 "2023-10-07T21:08:01Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![steffahn](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/steffahn/32/13288_2.png) [@steffahn](https://internals.rust-lang.org/u/steffahn)\
**Post date:** [October 7, 2023, 9:19pm UTC](https://internals.rust-lang.org/t/why-am-i-not-allowed-to-move-arg-in-pin-map-unchecked/19664/2 "2023-10-07T21:19:55Z")

</div>

The highlighted sentence doesn’t make too much sense for `map_unchecked`. It looks to me like the documentation was copy-pasted from `map_unchecked_mut`, where the “You must guarantee that _[…]_ you do not move out of the argument you receive to the interior function.” provision makes a lot more sense. For `map_unchecked` though, the `&T` argument to the mapped function doesn’t provide anything above what `Pin<&T>` already gave us, as `Pin<&T> -> &T` is safe via dereferencing or [`get_ref`](https://doc.rust-lang.org/std/pin/struct.Pin.html#method.get_ref), anyways - so the unsafe part is merely about the return `&U` being wrapped into `Pin<&U>`.

* * *

Regarding your comment / example with `RefCell`, I cannot quite follow that. Note however that `RefCell` cannot soundly do structural pinning anyways, since a `Pin<&RefCell<T>>` allows mutable (non-pinned) access to the contained value via [`get_ref`](https://doc.rust-lang.org/std/pin/struct.Pin.html#method.get_ref) (which gives us the `&RefCell<T>`) and [`borrow_mut`](https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.borrow_mut) (which then gives `&mut T`), anyways.

---

_[View the full topic](https://internals.rust-lang.org/t/why-am-i-not-allowed-to-move-arg-in-pin-map-unchecked/19664)._
