aboutsummaryrefslogtreecommitdiff
path: root/src/square.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/square.rs')
-rw-r--r--src/square.rs41
1 files changed, 18 insertions, 23 deletions
diff --git a/src/square.rs b/src/square.rs
index c7f185e..f94f065 100644
--- a/src/square.rs
+++ b/src/square.rs
@@ -1,4 +1,4 @@
-use std::{str::Chars, fmt::Display};
+use std::{fmt::Display, str::Chars};
use crate::bitboard::Bitboard;
@@ -6,6 +6,7 @@ use crate::bitboard::Bitboard;
#[allow(dead_code)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, num_enum::FromPrimitive)]
#[repr(u8)]
+#[rustfmt::skip]
pub enum Square {
#[default]
A1, B1, C1, D1, E1, F1, G1, H1,
@@ -54,29 +55,25 @@ impl Square {
pub fn from_notation(chars: &mut Chars) -> Result<Self, String> {
let file = match chars.next() {
- Some(ch) => {
- match ch {
- 'a' => 0,
- 'b' => 1,
- 'c' => 2,
- 'd' => 3,
- 'e' => 4,
- 'f' => 5,
- 'g' => 6,
- 'h' => 7,
- _ => return Err(String::from("Incorrect file!"))
- }
+ Some(ch) => match ch {
+ 'a' => 0,
+ 'b' => 1,
+ 'c' => 2,
+ 'd' => 3,
+ 'e' => 4,
+ 'f' => 5,
+ 'g' => 6,
+ 'h' => 7,
+ _ => return Err(String::from("Incorrect file!")),
},
- None => return Err(String::from("Missing file"))
+ None => return Err(String::from("Missing file")),
};
let rank = match chars.next() {
- Some(ch) => {
- match ch.to_digit(10) {
- Some(digit) => digit - 1,
- None => return Err(String::from("Incorrect rank"))
- }
- }
- None => return Err(String::from("Missing rank"))
+ Some(ch) => match ch.to_digit(10) {
+ Some(digit) => digit - 1,
+ None => return Err(String::from("Incorrect rank")),
+ },
+ None => return Err(String::from("Missing rank")),
};
Ok(Self::from_coords(rank as u8, file))
@@ -97,5 +94,3 @@ impl Display for Square {
write!(f, "{}", notation)
}
}
-
-