Extract helper methods for enum trait implementations

This commit is contained in:
GarandPLG committed 2026-04-24 11:53:07 +02:00
1 parent cf843057c3
commit c24862dd48
2 files changed
+43 -54

No files matched your search

@@ -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()
}
}