Skip to content

Commit

Permalink
Replace .iter().copied() on arrays with .into_iter()
Browse files Browse the repository at this point in the history
  • Loading branch information
inthar-raven committed Apr 22, 2024
1 parent fd69b55 commit 1dc0b1b
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion common/src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub enum Dir {
impl Dir {
pub fn iter() -> impl ExactSizeIterator<Item = Self> + Clone {
use Dir::*;
[Left, Right, Down, Up, Forward, Back].iter().cloned()
[Left, Right, Down, Up, Forward, Back].into_iter()
}

/// Returns the unit vector corresponding to the direction.
Expand Down
2 changes: 1 addition & 1 deletion common/src/dodeca.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Side {

pub fn iter() -> impl ExactSizeIterator<Item = Self> {
use Side::*;
[A, B, C, D, E, F, G, H, I, J, K, L].iter().cloned()
[A, B, C, D, E, F, G, H, I, J, K, L].into_iter()
}

/// Whether `self` and `other` share an edge
Expand Down
4 changes: 2 additions & 2 deletions common/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Graph {
///
/// A node's length is defined as a its distance from the root node.
pub fn canonicalize(&self, mut chunk: ChunkId) -> Option<ChunkId> {
for side in chunk.vertex.canonical_sides().iter().cloned() {
for side in chunk.vertex.canonical_sides().into_iter() {
// missing neighbors are always longer
if let Some(neighbor) = self.neighbor(chunk.node, side) {
if self.length(neighbor) < self.length(chunk.node) {
Expand Down Expand Up @@ -392,7 +392,7 @@ mod tests {
"both the root and some other node are common neighbors"
);
assert!(common.contains(&NodeId::ROOT));
let other = common.iter().cloned().find(|&x| x != NodeId::ROOT).unwrap();
let other = common.into_iter().find(|&x| x != NodeId::ROOT).unwrap();
assert_eq!(graph.nodes[&other].length, 2);
}

Expand Down
2 changes: 1 addition & 1 deletion common/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ pub struct CoordAxisOutOfBounds;
impl CoordAxis {
/// Iterates through the the axes in ascending order
pub fn iter() -> impl ExactSizeIterator<Item = Self> {
[Self::X, Self::Y, Self::Z].iter().copied()
[Self::X, Self::Y, Self::Z].into_iter()
}

/// Returns the pair axes orthogonal to the current axis
Expand Down
2 changes: 1 addition & 1 deletion common/src/worldgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ mod test {

let enviros =
chunk_incident_enviro_factors(&g, ChunkId::new(NodeId::ROOT, Vertex::A)).unwrap();
for (i, max_elevation) in enviros.max_elevations.iter().cloned().enumerate() {
for (i, max_elevation) in enviros.max_elevations.into_iter().enumerate() {
println!("{i}, {max_elevation}");
assert_abs_diff_eq!(max_elevation, (i + 1) as f64, epsilon = 1e-8);
}
Expand Down
2 changes: 1 addition & 1 deletion server/src/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ impl Sim {
populate_fresh_nodes(&mut self.graph);

let mut fresh_voxel_data = vec![];
for fresh_node in fresh_nodes.iter().copied() {
for fresh_node in fresh_nodes.iter().cloned() {
for vertex in Vertex::iter() {
let chunk = ChunkId::new(fresh_node, vertex);
if let Some(voxel_data) = self.preloaded_voxel_data.remove(&chunk) {
Expand Down

0 comments on commit 1dc0b1b

Please sign in to comment.