Skip to content

Commit 324ba46

Browse files
Use field initialization shorthand (#7)
* Use field initialization shorthand Manually reviewed by iCodeSometime
1 parent ac8d8d1 commit 324ba46

5 files changed

Lines changed: 9 additions & 15 deletions

File tree

src/board_builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ impl BoardBuilder {
113113
) -> BoardBuilder {
114114
let mut result = BoardBuilder {
115115
pieces: [None; 64],
116-
side_to_move: side_to_move,
116+
side_to_move,
117117
castle_rights: [white_castle_rights, black_castle_rights],
118-
en_passant: en_passant,
118+
en_passant,
119119
};
120120

121121
for piece in pieces.into_iter() {

src/cache_table.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ impl<T: Copy + Clone + PartialEq + PartialOrd> CacheTable<T> {
4848
#[inline]
4949
pub fn add(&mut self, hash: u64, entry: T) {
5050
let e = unsafe { self.table.get_unchecked_mut((hash as usize) & self.mask) };
51-
*e = CacheTableEntry {
52-
hash: hash,
53-
entry: entry,
54-
};
51+
*e = CacheTableEntry { hash, entry };
5552
}
5653

5754
/// Replace an entry in the hash table with a user-specified replacement policy specified by
@@ -82,10 +79,7 @@ impl<T: Copy + Clone + PartialEq + PartialOrd> CacheTable<T> {
8279
pub fn replace_if<F: Fn(T) -> bool>(&mut self, hash: u64, entry: T, replace: F) {
8380
let e = unsafe { self.table.get_unchecked_mut((hash as usize) & self.mask) };
8481
if replace(e.entry) {
85-
*e = CacheTableEntry {
86-
hash: hash,
87-
entry: entry,
88-
};
82+
*e = CacheTableEntry { hash, entry };
8983
}
9084
}
9185
}

src/chess_move.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ impl ChessMove {
2424
#[inline]
2525
pub fn new(source: Square, dest: Square, promotion: Option<Piece>) -> ChessMove {
2626
ChessMove {
27-
source: source,
28-
dest: dest,
29-
promotion: promotion,
27+
source,
28+
dest,
29+
promotion,
3030
}
3131
}
3232

src/gen_tables/magic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fn generate_magic(sq: Square, piece: Piece, cur_offset: usize) -> usize {
7575

7676
let mut new_magic = Magic {
7777
magic_number: EMPTY,
78-
mask: mask,
78+
mask,
7979
offset: new_offset as u32,
8080
rightshift: ((questions.len() as u64).leading_zeros() + 1) as u8,
8181
};

src/movegen/movegen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl SquareAndBitBoard {
2222
SquareAndBitBoard {
2323
square: sq,
2424
bitboard: bb,
25-
promotion: promotion,
25+
promotion,
2626
}
2727
}
2828
}

0 commit comments

Comments
 (0)