Skip to content

Commit dd0ae3d

Browse files
committed
feat: minor refactoring
1 parent 1f37e2a commit dd0ae3d

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

src/chunk.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1-
use glam::Vec3;
2-
use std::ffi::c_void;
3-
use std::sync::{Arc, Mutex, Weak};
4-
5-
use wgpu::util::DeviceExt;
6-
7-
use crate::world::World;
81
use crate::{
92
blocks::{
103
block::{Block, BlockVertexData, FaceDirections},
114
block_type::BlockType,
125
},
13-
world::{NoiseData, CHUNK_HEIGHT, CHUNK_SIZE, NOISE_CHUNK_PER_ROW, NOISE_SIZE},
6+
world::{NoiseData, CHUNK_SIZE, NOISE_CHUNK_PER_ROW, NOISE_SIZE},
147
};
8+
use glam::Vec3;
9+
use std::sync::{Arc, Mutex};
10+
use wgpu::util::DeviceExt;
1511

1612
pub type BlockVec = Vec<Vec<Option<Arc<Mutex<Block>>>>>;
1713

1814
pub struct Chunk {
19-
// probably there needs to be a cube type with more info ( regarding type, etc. )
2015
pub x: i32,
2116
pub y: i32,
2217
pub blocks: BlockVec,

src/world.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ impl World {
6666
.chunks
6767
.iter()
6868
.enumerate()
69-
.find(|(i, c)| {
69+
.find(|(_, c)| {
7070
let c = c.lock().unwrap();
71-
return c.x == chunk_coords.0 && c.y == chunk_coords.1;
71+
c.x == chunk_coords.0 && c.y == chunk_coords.1
7272
})
7373
.expect("Cannot delete a block from unloaded chunk");
7474

@@ -112,9 +112,9 @@ impl World {
112112
.chunks
113113
.iter()
114114
.enumerate()
115-
.find(|(i, c)| {
115+
.find(|(_, c)| {
116116
let c = c.lock().unwrap();
117-
return c.x == chunk_coords.0 && c.y == chunk_coords.1;
117+
c.x == chunk_coords.0 && c.y == chunk_coords.1
118118
})
119119
.expect("Cannot delete a block from unloaded chunk");
120120

@@ -154,7 +154,7 @@ impl World {
154154

155155
let chunk = self.chunks.iter().find(|c| {
156156
let c = c.lock().unwrap();
157-
return c.x == chunk_x && c.y == chunk_y;
157+
c.x == chunk_x && c.y == chunk_y
158158
})?;
159159
let chunk = chunk.lock().unwrap();
160160

0 commit comments

Comments
 (0)