generated from GarandPLG/rust-flake-template
Use VecDeque for tasks and marked cells
Replace `Vec` with `VecDeque` in `BoardState` marked cells, `DiggingTask` path, and `MinerUnit` tasks to enable efficient push/pop operations. Remove the `Copy` trait from several structs and enums, adjust derives accordingly, and use `as_ref` in `Option<Units>` implementations to avoid consuming the option. Update cell rendering to clone widgets and adjust `CellWidget::get_option_unit` to return a cloned `Option<Units>`. Add necessary `VecDeque` imports.
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
use crate::app::widgets::CellWidget;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct DiggingTask {
|
||||
// path: Vec<(usize, usize)>,
|
||||
path: VecDeque<(usize, usize)>,
|
||||
}
|
||||
|
||||
impl DiggingTask {
|
||||
pub fn new(path: Vec<(u16, u16)>) -> Self {
|
||||
Self {
|
||||
// path
|
||||
}
|
||||
pub fn new(path: VecDeque<(usize, usize)>) -> Self {
|
||||
Self { path }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::app::states::skirmish_states::tasks::DiggingTask;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum Tasks {
|
||||
Digging(DiggingTask),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user