Skip to content

Commit 86549e9

Browse files
authored
Merge pull request #505 from poweron0102/main
Add const to some functions.
2 parents 92fc406 + f47b2ff commit 86549e9

File tree

9 files changed

+20
-20
lines changed

9 files changed

+20
-20
lines changed

src/helpers/hex_grid/axial.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ pub const UNIT_R: AxialPos = AxialPos { q: 0, r: -1 };
219219
pub const UNIT_S: AxialPos = AxialPos { q: 1, r: -1 };
220220

221221
impl AxialPos {
222-
pub fn new(q: i32, r: i32) -> Self {
222+
pub const fn new(q: i32, r: i32) -> Self {
223223
Self { q, r }
224224
}
225225

@@ -485,7 +485,7 @@ pub struct FractionalAxialPos {
485485
}
486486

487487
impl FractionalAxialPos {
488-
pub fn new(q: f32, r: f32) -> Self {
488+
pub const fn new(q: f32, r: f32) -> Self {
489489
Self { q, r }
490490
}
491491

src/helpers/hex_grid/cube.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl Mul<CubePos> for u32 {
103103
}
104104

105105
impl CubePos {
106-
pub fn new(q: i32, r: i32, s: i32) -> Self {
106+
pub const fn new(q: i32, r: i32, s: i32) -> Self {
107107
Self { q, r, s }
108108
}
109109

@@ -139,7 +139,7 @@ impl From<FractionalAxialPos> for FractionalCubePos {
139139
}
140140

141141
impl FractionalCubePos {
142-
pub fn new(q: f32, r: f32, s: f32) -> Self {
142+
pub const fn new(q: f32, r: f32, s: f32) -> Self {
143143
Self { q, r, s }
144144
}
145145

src/helpers/hex_grid/offset.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub struct RowOddPos {
1414
}
1515

1616
impl RowOddPos {
17-
pub fn new(q: i32, r: i32) -> Self {
17+
pub const fn new(q: i32, r: i32) -> Self {
1818
Self { q, r }
1919
}
2020

@@ -105,7 +105,7 @@ pub struct RowEvenPos {
105105
}
106106

107107
impl RowEvenPos {
108-
pub fn new(q: i32, r: i32) -> Self {
108+
pub const fn new(q: i32, r: i32) -> Self {
109109
Self { q, r }
110110
}
111111

@@ -196,7 +196,7 @@ pub struct ColOddPos {
196196
}
197197

198198
impl ColOddPos {
199-
pub fn new(q: i32, r: i32) -> Self {
199+
pub const fn new(q: i32, r: i32) -> Self {
200200
Self { q, r }
201201
}
202202

@@ -287,7 +287,7 @@ pub struct ColEvenPos {
287287
}
288288

289289
impl ColEvenPos {
290-
pub fn new(q: i32, r: i32) -> Self {
290+
pub const fn new(q: i32, r: i32) -> Self {
291291
Self { q, r }
292292
}
293293

src/helpers/square_grid/diamond.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl From<&SquarePos> for DiamondPos {
123123
}
124124

125125
impl DiamondPos {
126-
pub fn new(x: i32, y: i32) -> Self {
126+
pub const fn new(x: i32, y: i32) -> Self {
127127
Self { x, y }
128128
}
129129

src/helpers/square_grid/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl From<StaggeredPos> for SquarePos {
101101
}
102102

103103
impl SquarePos {
104-
pub fn new(x: i32, y: i32) -> Self {
104+
pub const fn new(x: i32, y: i32) -> Self {
105105
Self { x, y }
106106
}
107107

src/helpers/square_grid/staggered.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl Mul<StaggeredPos> for i32 {
9090
}
9191

9292
impl StaggeredPos {
93-
pub fn new(x: i32, y: i32) -> Self {
93+
pub const fn new(x: i32, y: i32) -> Self {
9494
Self { x, y }
9595
}
9696

src/map/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ pub struct TilemapSize {
6767
}
6868

6969
impl TilemapSize {
70-
pub fn new(x: u32, y: u32) -> Self {
70+
pub const fn new(x: u32, y: u32) -> Self {
7171
Self { x, y }
7272
}
7373

74-
pub fn count(&self) -> usize {
74+
pub const fn count(&self) -> usize {
7575
(self.x * self.y) as usize
7676
}
7777
}
@@ -214,7 +214,7 @@ pub struct TilemapTileSize {
214214
}
215215

216216
impl TilemapTileSize {
217-
pub fn new(x: f32, y: f32) -> Self {
217+
pub const fn new(x: f32, y: f32) -> Self {
218218
Self { x, y }
219219
}
220220
}
@@ -259,7 +259,7 @@ pub struct TilemapGridSize {
259259
}
260260

261261
impl TilemapGridSize {
262-
pub fn new(x: f32, y: f32) -> Self {
262+
pub const fn new(x: f32, y: f32) -> Self {
263263
Self { x, y }
264264
}
265265
}
@@ -304,11 +304,11 @@ impl From<TilemapSpacing> for Vec2 {
304304
}
305305

306306
impl TilemapSpacing {
307-
pub fn new(x: f32, y: f32) -> Self {
307+
pub const fn new(x: f32, y: f32) -> Self {
308308
Self { x, y }
309309
}
310310

311-
pub fn zero() -> Self {
311+
pub const fn zero() -> Self {
312312
Self { x: 0.0, y: 0.0 }
313313
}
314314
}
@@ -322,7 +322,7 @@ pub struct TilemapTextureSize {
322322
}
323323

324324
impl TilemapTextureSize {
325-
pub fn new(x: f32, y: f32) -> Self {
325+
pub const fn new(x: f32, y: f32) -> Self {
326326
Self { x, y }
327327
}
328328
}

src/render/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub struct DefaultSampler(ImageSamplerDescriptor);
6666
pub(crate) struct RenderChunkSize(UVec2);
6767

6868
impl RenderChunkSize {
69-
pub fn new(chunk_size: UVec2) -> RenderChunkSize {
69+
pub const fn new(chunk_size: UVec2) -> RenderChunkSize {
7070
RenderChunkSize(chunk_size)
7171
}
7272

src/tiles/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub struct TilePos {
1919
}
2020

2121
impl TilePos {
22-
pub fn new(x: u32, y: u32) -> Self {
22+
pub const fn new(x: u32, y: u32) -> Self {
2323
Self { x, y }
2424
}
2525

0 commit comments

Comments
 (0)