Extract helper methods for enum trait implementations

This commit is contained in:
2026-04-24 11:53:07 +02:00
parent cf843057c3
commit c24862dd48
2 changed files with 43 additions and 54 deletions
@@ -8,23 +8,25 @@ pub enum Units {
Miner(MinerUnit),
}
impl Units {
fn unit(&self) -> &dyn Unit {
match self {
Self::Miner(m) => m,
}
}
}
impl Unit for Units {
fn get_tag(&self) -> char {
match self {
Self::Miner(m) => m.get_tag(),
}
self.unit().get_tag()
}
fn get_name(&self) -> &'static str {
match self {
Self::Miner(m) => m.get_name(),
}
self.unit().get_name()
}
fn get_owner(&self) -> Players {
match self {
Self::Miner(m) => m.get_owner(),
}
self.unit().get_owner()
}
}