浏览代码

LibChess: Add convenience constructor for Chess::Square

It didn't feel right to add sv suffixes to 2-character strings, so I
added this convenience constructor.
sin-ack 3 年之前
父节点
当前提交
6c46383e23
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      Userland/Libraries/LibChess/Chess.h

+ 7 - 0
Userland/Libraries/LibChess/Chess.h

@@ -57,7 +57,14 @@ constexpr Piece EmptyPiece = { Color::None, Type::None };
 struct Square {
     i8 rank; // zero indexed;
     i8 file;
+
     Square(StringView name);
+
+    Square(char const name[3])
+        : Square({ name, 2 })
+    {
+    }
+
     Square(int const& rank, int const& file)
         : rank(rank)
         , file(file)