# Hands-on Rust: why a second clone?

**URL:** <https://forum.devtalk.com/t/hands-on-rust-why-a-second-clone/5026>\
**Category:** PragProg Customers\
**Tags:** question, book-hands-on-rust\
**Created:** [13 December 2020 14:59 UTC](https://forum.devtalk.com/t/hands-on-rust-why-a-second-clone/5026 "2020-12-13T14:59:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikecargal](https://forum.devtalk.com/user_avatar/forum.devtalk.com/mikecargal/32/1289_2.png) [@mikecargal](https://forum.devtalk.com/u/mikecargal)\
**Post date:** [13 December 2020 14:59 UTC](https://forum.devtalk.com/t/hands-on-rust-why-a-second-clone/5026/1 "2020-12-13T14:59:20Z")

</div>

Title: Hands-On Rust (Chapter 10: Iterating Away the Chaos)

in the `iteration` function, why is it necessary to return a clone of `new_tiles` (which was already cloned from `map.tiles`?)

---

<div class="post-metadata">

**Author:** ![herbert](https://forum.devtalk.com/user_avatar/forum.devtalk.com/herbert/32/1233_2.png) [@herbert](https://forum.devtalk.com/u/herbert)\
**Post date:** [13 December 2020 15:08 UTC](https://forum.devtalk.com/t/hands-on-rust-why-a-second-clone/5026/2 "2020-12-13T15:08:00Z")

</div>

That’s actually a very good question. It appears to work fine without it (it replaces the copy with a move; both compile down to `memcpy` so it winds up not making a lot of difference in terms of performance). My notes indicate that I had problems with an earlier Rust compiler there, so I’m going to test the heck out of it before committing the change. Thanks!

---

<div class="post-metadata">

**Author:** ![mikecargal](https://forum.devtalk.com/user_avatar/forum.devtalk.com/mikecargal/32/1289_2.png) [@mikecargal](https://forum.devtalk.com/u/mikecargal)\
**Post date:** [13 December 2020 15:45 UTC](https://forum.devtalk.com/t/hands-on-rust-why-a-second-clone/5026/3 "2020-12-13T15:45:00Z")

</div>

Yeah, I skipped it, and now that I have things wired up it seems to work fine. Guess I’ll let you know if I stumble across some issue.

---

<div class="post-metadata">

**Author:** ![herbert](https://forum.devtalk.com/user_avatar/forum.devtalk.com/herbert/32/1233_2.png) [@herbert](https://forum.devtalk.com/u/herbert)\
**Post date:** [13 December 2020 21:26 UTC](https://forum.devtalk.com/t/hands-on-rust-why-a-second-clone/5026/4 "2020-12-13T21:26:44Z")

</div>

I have a build (I wish I had room to include it in the book) that plays itself over and over. After a few hours, no errors with the clone omitted - so it’ll be trimmed for the next beta. Thanks! 🙂
