Skip to content

Commit d5e80bf

Browse files
committed
libriichi: fix cargo clippy issues
1 parent 8cd9d51 commit d5e80bf

File tree

10 files changed

+14
-14
lines changed

10 files changed

+14
-14
lines changed

libriichi/src/algo/sp/state.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl From<InitState> for State {
5454
}
5555

5656
impl State {
57-
pub(super) fn discard(&mut self, tile: Tile) {
57+
pub(super) const fn discard(&mut self, tile: Tile) {
5858
self.tehai[tile.deaka().as_usize()] -= 1;
5959
match tile.as_u8() {
6060
tu8!(5mr) => self.akas_in_hand[0] = false,
@@ -64,7 +64,7 @@ impl State {
6464
}
6565
}
6666

67-
pub(super) fn undo_discard(&mut self, tile: Tile) {
67+
pub(super) const fn undo_discard(&mut self, tile: Tile) {
6868
self.tehai[tile.deaka().as_usize()] += 1;
6969
match tile.as_u8() {
7070
tu8!(5mr) => self.akas_in_hand[0] = true,
@@ -74,7 +74,7 @@ impl State {
7474
}
7575
}
7676

77-
pub(super) fn deal(&mut self, tile: Tile) {
77+
pub(super) const fn deal(&mut self, tile: Tile) {
7878
self.tiles_in_wall[tile.deaka().as_usize()] -= 1;
7979
match tile.as_u8() {
8080
tu8!(5mr) => self.akas_in_wall[0] = false,
@@ -85,7 +85,7 @@ impl State {
8585
self.undo_discard(tile);
8686
}
8787

88-
pub(super) fn undo_deal(&mut self, tile: Tile) {
88+
pub(super) const fn undo_deal(&mut self, tile: Tile) {
8989
self.discard(tile);
9090
self.tiles_in_wall[tile.deaka().as_usize()] += 1;
9191
match tile.as_u8() {

libriichi/src/arena/board.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ impl BoardState {
293293
// no need to broadcast
294294
}
295295

296-
fn update_nagashi_mangan_and_four_wind(&mut self, ev: &Event) {
296+
const fn update_nagashi_mangan_and_four_wind(&mut self, ev: &Event) {
297297
match *ev {
298298
Event::Dahai { actor, pai, .. } if !pai.is_yaokyuu() => {
299299
self.can_nagashi_mangan[actor as usize] = false;

libriichi/src/arena/one_vs_three.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl OneVsThree {
138138
);
139139

140140
let seeds: Vec<_> = (seed_start.0..seed_start.0 + seed_count)
141-
.flat_map(|seed| iter::repeat((seed, seed_start.1)).take(4))
141+
.flat_map(|seed| iter::repeat_n((seed, seed_start.1), 4))
142142
.collect();
143143

144144
let challenger_player_ids: Vec<_> = (0..4).cycle().take(seed_count as usize * 4).collect();

libriichi/src/arena/two_vs_two.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl TwoVsTwo {
135135
);
136136

137137
let seeds: Vec<_> = (seed_start.0..seed_start.0 + seed_count)
138-
.flat_map(|seed| iter::repeat((seed, seed_start.1)).take(2))
138+
.flat_map(|seed| iter::repeat_n((seed, seed_start.1), 2))
139139
.collect();
140140

141141
let challenger_player_ids_per_seed = [

libriichi/src/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ where
1818
}
1919

2020
#[inline]
21-
pub fn rows(&self) -> usize {
21+
pub const fn rows(&self) -> usize {
2222
self.arr.len() / COLS
2323
}
2424

libriichi/src/dataset/gameplay.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ impl Gameplay {
379379
// Check if the POV is one of those who made Hora.
380380
for ev in &wnd[1..] {
381381
match *ev {
382-
Event::EndKyoku { .. } => break,
382+
Event::EndKyoku => break,
383383
Event::Hora { actor, .. } if actor == self.player_id => {
384384
ret = Some(43);
385385
break;

libriichi/src/dataset/invisible.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl Invisible {
116116
.into_iter()
117117
.enumerate()
118118
.filter(|&(_, count)| count > 0)
119-
.flat_map(|(tid, count)| iter::repeat(must_tile!(tid)).take(count as usize))
119+
.flat_map(|(tid, count)| iter::repeat_n(must_tile!(tid), count as usize))
120120
.collect();
121121
filler.shuffle(&mut rng());
122122

libriichi/src/mjai/bot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl Bot {
5454
self.log.clear();
5555
self.agent.end_kyoku(0)?;
5656
}
57-
Event::EndGame { .. } => {
57+
Event::EndGame => {
5858
self.agent.end_game(0, &Default::default())?;
5959
}
6060
_ => {

libriichi/src/mjai/event.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ impl Event {
185185
}
186186

187187
pub fn augment(&mut self) {
188-
fn swap_tile(t: &mut Tile) {
188+
const fn swap_tile(t: &mut Tile) {
189189
*t = t.augment();
190190
}
191191

libriichi/src/state/update.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ impl PlayerState {
662662
Ok(())
663663
}
664664

665-
fn reach(&mut self, actor: u8) {
665+
const fn reach(&mut self, actor: u8) {
666666
let actor_rel = self.rel(actor);
667667
self.riichi_declared[actor_rel] = true;
668668
if actor_rel == 0 {
@@ -952,7 +952,7 @@ impl PlayerState {
952952
}
953953
}
954954

955-
pub(super) fn update_doras_owned(&mut self, actor_rel: usize, tile: Tile) {
955+
pub(super) const fn update_doras_owned(&mut self, actor_rel: usize, tile: Tile) {
956956
self.doras_owned[actor_rel] += self.dora_factor[tile.deaka().as_usize()];
957957
if tile.is_aka() {
958958
self.doras_owned[actor_rel] += 1;

0 commit comments

Comments
 (0)