···
pub fn new(x: u16, y: u16) -> Self {
-
Vector2u16 {x: x, y: y}
···
pub fn new(first_pos: Vector2u16, last_pos: Vector2u16) -> Self {
-
Boat { first_pos: first_pos, last_pos: last_pos }
···
return Err(ParserError::InvalidCoordCount);
-
Ok(Boat::new(create_coord(coordinates[0])?, create_coord(coordinates[1])?))
fn create_coord(coord_str: &str) -> Result<Vector2u16, ParserError> {
···
Ok(Vector2u16::new(col, row))
···
let coord3 = create_coord("H8")?;
···
fn test_create_ship() -> Result<(), ParserError> {
let ship = create_ship("C4:B1")?;
assert_eq!(ship.first_pos.x, 2);
assert_eq!(ship.first_pos.y, 3);
assert_eq!(ship.last_pos.x, 1);
···
let ships = parse_ships(&mut &file[..])?;
-
assert_eq!(ships[0], Boat::new(Vector2u16::new(1, 3), Vector2u16::new(2, 1)));
-
assert_eq!(ships[1], Boat::new(Vector2u16::new(3, 0), Vector2u16::new(5, 2)));
-
assert_eq!(ships[2], Boat::new(Vector2u16::new(5, 0), Vector2u16::new(5, 4)));
-
assert_eq!(ships[3], Boat::new(Vector2u16::new(0, 0), Vector2u16::new(0, 1)));
···
pub fn new(x: u16, y: u16) -> Self {
+
Vector2u16 { x: x, y: y }
···
pub fn new(first_pos: Vector2u16, last_pos: Vector2u16) -> Self {
···
return Err(ParserError::InvalidCoordCount);
+
create_coord(coordinates[0])?,
+
create_coord(coordinates[1])?,
fn create_coord(coord_str: &str) -> Result<Vector2u16, ParserError> {
···
Ok(Vector2u16::new(col, row))
···
let coord3 = create_coord("H8")?;
···
fn test_create_ship() -> Result<(), ParserError> {
let ship = create_ship("C4:B1")?;
assert_eq!(ship.first_pos.x, 2);
assert_eq!(ship.first_pos.y, 3);
assert_eq!(ship.last_pos.x, 1);
···
let ships = parse_ships(&mut &file[..])?;
+
Boat::new(Vector2u16::new(1, 3), Vector2u16::new(2, 1))
+
Boat::new(Vector2u16::new(3, 0), Vector2u16::new(5, 2))
+
Boat::new(Vector2u16::new(5, 0), Vector2u16::new(5, 4))
+
Boat::new(Vector2u16::new(0, 0), Vector2u16::new(0, 1))