Skip to content

Commit

Permalink
Fix clippy errors related to IntoIter::new (#3269)
Browse files Browse the repository at this point in the history
# Objective

Fixes recent pipeline errors:
```
error: use of deprecated associated function `std::array::IntoIter::<T, N>::new`: use `IntoIterator::into_iter` instead
   --> crates/bevy_render/src/mesh/mesh.rs:467:54
    |
467 |             .flat_map(|normal| std::array::IntoIter::new([normal, normal, normal]))
    |                                                      ^^^
    |
    = note: `-D deprecated` implied by `-D warnings`

   Compiling bevy_render2 v0.5.0 (/home/runner/work/bevy/bevy/pipelined/bevy_render2)
error: use of deprecated associated function `std::array::IntoIter::<T, N>::new`: use `IntoIterator::into_iter` instead
   --> pipelined/bevy_render2/src/mesh/mesh/mod.rs:287:54
    |
287 |             .flat_map(|normal| std::array::IntoIter::new([normal, normal, normal]))
    |                                                      ^^^
    |
    = note: `-D deprecated` implied by `-D warnings`

error: could not compile `bevy_render` due to previous error
```

## Solution

- Replaced `IntoIter::new` with `IntoIterator::into_iter`

## Suggestions

For me it looks like two equivalent `Mesh` structs with the same methods. Should we refactor it? Or, they will be different in the near future?


Co-authored-by: CrazyRoka <rokarostuk@gmail.com>
  • Loading branch information
CrazyRoka and CrazyRoka committed Dec 6, 2021
1 parent 4423a2f commit a4e8553
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_render/src/mesh/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ impl Mesh {
let normals: Vec<_> = positions
.chunks_exact(3)
.map(|p| face_normal(p[0], p[1], p[2]))
.flat_map(|normal| std::array::IntoIter::new([normal, normal, normal]))
.flat_map(|normal| [normal; 3])
.collect();

self.set_attribute(Mesh::ATTRIBUTE_NORMAL, normals);
Expand Down
2 changes: 1 addition & 1 deletion pipelined/bevy_render2/src/mesh/mesh/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ impl Mesh {
let normals: Vec<_> = positions
.chunks_exact(3)
.map(|p| face_normal(p[0], p[1], p[2]))
.flat_map(|normal| std::array::IntoIter::new([normal, normal, normal]))
.flat_map(|normal| [normal; 3])
.collect();

self.set_attribute(Mesh::ATTRIBUTE_NORMAL, normals);
Expand Down

0 comments on commit a4e8553

Please sign in to comment.