So i'm trying to take a ppdl domain and write him in rust
My problem is a Grid HorizontalCar HorizontalTruck VerticalCar VerticalTruck each one of them is a struct
This is the traits i have in my projects -
pub trait Vehicle {
fn positions(&self) -> Vec<(usize, usize)>; // Get occupied positions
fn name(&self) -> &str; // Get the object's name
fn as_any(&self) -> &dyn Any; // Enables downcasting
}
pub trait HorizontalVehicle: Vehicle {
fn move_left(&mut self, grid: &mut Grid) -> Result<String, String>;
fn move_right(&mut self, grid: &mut Grid) -> Result<String, String>;
}
pub trait VerticalVehicle: Vehicle {
fn move_up(&mut self, grid: &mut Grid) -> Result<String, String>;
fn move_down(&mut self, grid: &mut Grid) -> Result<String, String>;
}```
so i have impl in the each struct for Vehicle and to Verical\horizontalVehicle depend on what he his
All the logic working well
My problem is now i want to create a generate_moves that possible from a grid ,
The function need to take the grid and make new grids by move each object 1 time and i get a new grid
I have alot of problem with this because i'm trying to do OOP
```rust
pub objects: Vec<Box<dyn Vehicle>>,
this how i try to save the objects ...
and there is problem with the size and with the cloning can some one help me ? idc to share the project file