···
pub fn new(x: u16, y: u16) -> Self {
25
-
Vector2u16 {x: x, y: y}
25
+
Vector2u16 { x: x, y: y }
···
pub fn new(first_pos: Vector2u16, last_pos: Vector2u16) -> Self {
37
-
Boat { first_pos: first_pos, last_pos: last_pos }
38
+
first_pos: first_pos,
···
return Err(ParserError::InvalidCoordCount);
74
-
Ok(Boat::new(create_coord(coordinates[0])?, create_coord(coordinates[1])?))
77
+
create_coord(coordinates[0])?,
78
+
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[..])?;
162
-
assert_eq!(ships[0], Boat::new(Vector2u16::new(1, 3), Vector2u16::new(2, 1)));
163
-
assert_eq!(ships[1], Boat::new(Vector2u16::new(3, 0), Vector2u16::new(5, 2)));
164
-
assert_eq!(ships[2], Boat::new(Vector2u16::new(5, 0), Vector2u16::new(5, 4)));
165
-
assert_eq!(ships[3], Boat::new(Vector2u16::new(0, 0), Vector2u16::new(0, 1)));
168
+
Boat::new(Vector2u16::new(1, 3), Vector2u16::new(2, 1))
172
+
Boat::new(Vector2u16::new(3, 0), Vector2u16::new(5, 2))
176
+
Boat::new(Vector2u16::new(5, 0), Vector2u16::new(5, 4))
180
+
Boat::new(Vector2u16::new(0, 0), Vector2u16::new(0, 1))