That’s a good point; clone can be expensive (it’s remarkable how well LLVM optimizes it out, especially on release builds). There’s a bit of compiler magic that notices that it’s basically a set of memcpy
calls under the hood, and elides them. I like your approach better, though - it’s dangerous to rely on the compiler noticing an optimization when you can tell it what you want.
Adding an is_visible
method is also a great idea. I’ll see if I can refactor the book code a little.
I’ll try and merge this into the next beta. Thank you!