no_std
This commit is contained in:
parent
c0e915f1b4
commit
00261d95c1
9 changed files with 102 additions and 96 deletions
40
src/board.rs
40
src/board.rs
|
|
@ -72,7 +72,7 @@ impl Color {
|
|||
}
|
||||
}
|
||||
|
||||
impl std::ops::Not for Color {
|
||||
impl core::ops::Not for Color {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn not(self) -> Self::Output {
|
||||
|
|
@ -126,7 +126,7 @@ impl File {
|
|||
#[inline]
|
||||
pub const unsafe fn new_unchecked(index: u8) -> Self {
|
||||
debug_assert!(index < 8);
|
||||
unsafe { std::mem::transmute(index) }
|
||||
unsafe { core::mem::transmute(index) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -166,9 +166,9 @@ impl File {
|
|||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for File {
|
||||
impl core::fmt::Display for File {
|
||||
#[inline]
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||
write!(f, "{}", self.to_char())
|
||||
}
|
||||
}
|
||||
|
|
@ -216,7 +216,7 @@ impl Rank {
|
|||
#[inline]
|
||||
pub const unsafe fn new_unchecked(index: u8) -> Self {
|
||||
debug_assert!(index < 8);
|
||||
unsafe { std::mem::transmute(index) }
|
||||
unsafe { core::mem::transmute(index) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -261,9 +261,9 @@ impl Rank {
|
|||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Rank {
|
||||
impl core::fmt::Display for Rank {
|
||||
#[inline]
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||
write!(f, "{}", self.to_char())
|
||||
}
|
||||
}
|
||||
|
|
@ -315,7 +315,7 @@ impl Square {
|
|||
#[inline]
|
||||
pub const unsafe fn new_unchecked(index: u8) -> Self {
|
||||
debug_assert!(index < 64);
|
||||
unsafe { std::mem::transmute(index) }
|
||||
unsafe { core::mem::transmute(index) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -422,9 +422,9 @@ impl Square {
|
|||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Square {
|
||||
impl core::fmt::Display for Square {
|
||||
#[inline]
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||
f.write_str(self.to_str())
|
||||
}
|
||||
}
|
||||
|
|
@ -432,14 +432,14 @@ impl std::fmt::Display for Square {
|
|||
/// An error while parsing a [`Square`].
|
||||
#[derive(Debug)]
|
||||
pub struct ParseSquareError;
|
||||
impl std::fmt::Display for ParseSquareError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
impl core::fmt::Display for ParseSquareError {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
f.write_str("invalid square syntax")
|
||||
}
|
||||
}
|
||||
impl std::error::Error for ParseSquareError {}
|
||||
impl core::error::Error for ParseSquareError {}
|
||||
|
||||
impl std::str::FromStr for Square {
|
||||
impl core::str::FromStr for Square {
|
||||
type Err = ParseSquareError;
|
||||
#[inline]
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
|
|
@ -484,7 +484,7 @@ impl OptionSquare {
|
|||
|
||||
#[inline]
|
||||
pub(crate) fn from_square(square: Square) -> Self {
|
||||
unsafe { std::mem::transmute(square) }
|
||||
unsafe { core::mem::transmute(square) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -558,7 +558,7 @@ impl Role {
|
|||
#[inline]
|
||||
pub(crate) unsafe fn transmute(i: u8) -> Self {
|
||||
debug_assert!(i >= 1 && i < 7);
|
||||
unsafe { std::mem::transmute(i) }
|
||||
unsafe { core::mem::transmute(i) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -574,14 +574,14 @@ impl<T> ByRole<T> {
|
|||
#[inline]
|
||||
pub const fn get(&self, role: Role) -> &T {
|
||||
let i = unsafe { (role as usize).unchecked_sub(1) };
|
||||
unsafe { std::hint::assert_unchecked(i < 6) };
|
||||
unsafe { core::hint::assert_unchecked(i < 6) };
|
||||
&self.0[i]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn get_mut(&mut self, role: Role) -> &mut T {
|
||||
let i = unsafe { (role as usize).unchecked_sub(1) };
|
||||
unsafe { std::hint::assert_unchecked(i < 6) };
|
||||
unsafe { core::hint::assert_unchecked(i < 6) };
|
||||
&mut self.0[i]
|
||||
}
|
||||
|
||||
|
|
@ -673,11 +673,11 @@ impl Direction {
|
|||
#[inline]
|
||||
const unsafe fn transmute(value: u8) -> Self {
|
||||
debug_assert!(value < 8);
|
||||
unsafe { std::mem::transmute(value) }
|
||||
unsafe { core::mem::transmute(value) }
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Not for Direction {
|
||||
impl core::ops::Not for Direction {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn not(self) -> Self::Output {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue