Advertisement
cwchen

[Rust] Character class

Sep 3rd, 2017
3,419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.46 KB | None | 0 0
  1. pub struct Character {
  2.     // Creature become a member of Character
  3.    creature: Creature,
  4.  
  5.    // Other field omitted.
  6. }
  7.  
  8. impl Character {
  9.     pub fn new() -> Character {
  10.        let c = Creature::new();
  11.        Character{ creature: c }
  12.     }
  13. }
  14.  
  15. impl Priority for Character {
  16.     fn get_priority(&self) -> i32 {
  17.         self.creature.get_priority()
  18.     }
  19.  
  20.     fn set_priority(&mut self, value: i32) {
  21.         self.creature.set_priority(value);
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement