
mikecargal
Hands-on Rust: why a second clone?
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
?)
Marked As Solved

herbert
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!
Also Liked

mikecargal
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.

herbert
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!
Popular Prag Prog topics










Other popular topics









Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /zig
- /scala
- /html
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /sublime-text
- /react-native
- /kubuntu
- /arch-linux
- /ubuntu
- /revery
- /manjaro
- /django
- /spring
- /diversity
- /nodejs
- /lua
- /julia
- /slackware
- /c
- /neovim