misc
This commit is contained in:
parent
faccfbc1c5
commit
a6a00fc819
3 changed files with 97 additions and 94 deletions
26
src/board.rs
26
src/board.rs
|
|
@ -194,7 +194,7 @@ impl Rank {
|
|||
|
||||
#[inline]
|
||||
pub fn mirror(self) -> Self {
|
||||
unsafe { Self::transmute(7_u8.unchecked_sub(self as u8)) }
|
||||
unsafe { Self::transmute(!(self as u8)) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -263,7 +263,7 @@ impl Square {
|
|||
|
||||
#[inline]
|
||||
pub fn new(file: File, rank: Rank) -> Self {
|
||||
unsafe { Self::transmute(((rank as u8) << 3) + file as u8) }
|
||||
unsafe { Self::transmute(((rank as u8) << 3) | file as u8) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -278,7 +278,8 @@ impl Square {
|
|||
|
||||
#[inline]
|
||||
pub fn mirror(self) -> Self {
|
||||
Self::new(self.file(), self.rank().mirror())
|
||||
let sq = self as u8;
|
||||
unsafe { Self::transmute(sq & 0b000111 | (!sq & 0b111000)) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -389,18 +390,19 @@ impl std::str::FromStr for Square {
|
|||
}
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[allow(unused)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[repr(u8)]
|
||||
#[rustfmt::skip]
|
||||
pub(crate) enum OptionSquare {
|
||||
_A1, _B1, _C1, _D1, _E1, _F1, _G1, _H1,
|
||||
_A2, _B2, _C2, _D2, _E2, _F2, _G2, _H2,
|
||||
_A3, _B3, _C3, _D3, _E3, _F3, _G3, _H3,
|
||||
_A4, _B4, _C4, _D4, _E4, _F4, _G4, _H4,
|
||||
_A5, _B5, _C5, _D5, _E5, _F5, _G5, _H5,
|
||||
_A6, _B6, _C6, _D6, _E6, _F6, _G6, _H6,
|
||||
_A7, _B7, _C7, _D7, _E7, _F7, _G7, _H7,
|
||||
_A8, _B8, _C8, _D8, _E8, _F8, _G8, _H8,
|
||||
A1, B1, C1, D1, E1, F1, G1, H1,
|
||||
A2, B2, C2, D2, E2, F2, G2, H2,
|
||||
A3, B3, C3, D3, E3, F3, G3, H3,
|
||||
A4, B4, C4, D4, E4, F4, G4, H4,
|
||||
A5, B5, C5, D5, E5, F5, G5, H5,
|
||||
A6, B6, C6, D6, E6, F6, G6, H6,
|
||||
A7, B7, C7, D7, E7, F7, G7, H7,
|
||||
A8, B8, C8, D8, E8, F8, G8, H8,
|
||||
None,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue