3 #![allow(non_camel_case_types)]
15 pub fn speak(&mut self) { self.meow(); }
17 pub fn eat(&mut self) -> bool {
18 if self.how_hungry > 0 {
19 println!("OM NOM NOM");
24 println!("Not hungry!");
34 if self.meows % 5 == 0 {
40 fn cat(in_x : usize, in_y : isize, in_name: String) -> cat {
48 impl fmt::Display for cat {
49 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
50 write!(f, "{}", self.name)
54 fn print_out(thing: Box<dyn ToString>, expected: String) {
55 let actual = (*thing).to_string();
56 println!("{}", actual);
57 assert_eq!(actual.to_string(), expected);
61 let nyan: Box<dyn ToString> = Box::new(cat(0, 2, "nyan".to_string())) as Box<dyn ToString>;
62 print_out(nyan, "nyan".to_string());