From 9ca2cab1690f9ff77738bb00426910d888267eeb Mon Sep 17 00:00:00 2001 From: Aaditya Murthy Date: Tue, 10 Oct 2023 04:40:06 -0500 Subject: [PATCH] commit --- src/lib.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 929d9b3..f43f53c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,7 @@ use chess::{Board, ChessMove, Error, MoveGen, Piece, Square}; use wasm_bindgen::prelude::*; #[wasm_bindgen] -pub fn get_next_move(fen: &str) -> String { +pub fn get_next_move(fen: &str) -> JsValue { let res: Result = Board::from_str(fen); let board = match res { Ok(b) => b, @@ -14,7 +14,9 @@ pub fn get_next_move(fen: &str) -> String { for chess_move in movegen { // This move does not capture anything - return chess_move.to_string(); + return JsValue::from_str(&chess_move.to_string()); } - return ChessMove::new(Square::E4, Square::E4, Some(Piece::Queen)).to_string(); + return JsValue::from_str( + &ChessMove::new(Square::E4, Square::E4, Some(Piece::Queen)).to_string(), + ); }