#One set of getter/setter functions that get the type from the key or separate ones for each type?
16 messages · Page 1 of 1 (latest)
Assuming a single get is implemented, it's probably preferrable
That said, what type is Id?
Because if it's zero-sized, you can even remove it entirely
the getter/setter is wrapper around some HashMaps. It's been a while since I worked on that project. it might even be a Generic
I assume you have a finite list of types that could be stored in this thing. What is the relationship between these types?
It's just proporties for a game entities
strunt Agent {
i8s: HashMap<ID, i8>,
strings: HashMap<ID, String>
}
should you access the proporties with a generit getter/setter like
println!("{} wacks {}", actor.get(NAME), actee.get(NAME))
or shoulf it be
println!("{} wacks {}", actor.get_string(NAME), actee.get_string(NAME))
Probably two separate getters then. Although I'm not even sure if getters/setters are even needed here.
btw i think strings is not a great field name
That's not the actual code just something to explain the concept
because then you can't keep people from editing them
That and I've ran into the sistual when instead of storing the value you calculate it and if you use Getter/setters then you just have to change the struct whie if you where accessing the field direct you have to replace every where you where accessing it with the functions
@inland sequoiaidk what you're doing but I feel like this crate might be relevant https://lib.rs/crates/type-map
Oh yeah my favorit game Type Signatures & Tautologies