hecrj / coffee

An opinionated 2D game engine for Rust
https://docs.rs/coffee
MIT License
1.08k stars 55 forks source link

wgpu backend: Remove unneeded `cloned()` when creating texture arrays #108

Closed dlight closed 4 years ago

dlight commented 4 years ago

Related to #107

dlight commented 4 years ago

Also related to #7

dlight commented 4 years ago

After struggling a bit, it turns out there's two ways to write this without cloned

let slice: Vec<u8> = layers.iter().map(|i| i.iter()).flatten().map(|i| *i).collect();

let slice: Vec<u8> = layers.iter().map(|i| *i).flatten().map(|i| *i).collect();

(playground link)

But in the end, it probably doesn't matter because u8 is small and Copy (cloning it isn't "bad"). So I'm closing it.