Possible refactor: Cards as structs
Cards are currently represented as i32
s. An additional level of abstraction could be added by making cards a struct that internally stores its state using an i32
but has public methods for accessing specific parts of that state.
pub struct Card { state: i32 };
impl Card {
pub fn get_value(&self) -> i32 {
self.state & VALUE
}
};
Whether this should be done is to be determined based on how much external access to the card states is needed. Ideally, the library should require as few methods and types exposed to C as possible. If Blackjack can be implemented with the frontend having no direct access to the cards at all, this will make the Rust code more readable.