
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 Pragmatic Bookshelf topics








Modern front-end development for Rails, second edition - Struggling to get the first chapter to work


Other popular topics










Latest in Hands-on Rust
Latest in PragProg Customers
Latest (all)
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /rails
- /js
- /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
- /scala
- /html
- /zig
- /debian
- /nixos
- /lisp
- /agda
- /react-native
- /textmate
- /sublime-text
- /kubuntu
- /arch-linux
- /ubuntu
- /revery
- /manjaro
- /django
- /spring
- /diversity
- /nodejs
- /lua
- /slackware
- /julia
- /c
- /neovim