3 #![allow(non_camel_case_types)]
5 #![feature(box_syntax)]
17 pub fn speak(&mut self) { self.meow(); }
19 pub fn eat(&mut self) -> bool {
20 if self.how_hungry > 0 {
21 println!("OM NOM NOM");
26 println!("Not hungry!");
36 if self.meows % 5 == 0 {
42 fn cat(in_x : usize, in_y : isize, in_name: String) -> cat {
50 impl fmt::Display for cat {
51 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
52 write!(f, "{}", self.name)
56 fn print_out(thing: Box<dyn ToString>, expected: String) {
57 let actual = (*thing).to_string();
58 println!("{}", actual);
59 assert_eq!(actual.to_string(), expected);
63 let nyan: Box<dyn ToString> = box cat(0, 2, "nyan".to_string()) as Box<dyn ToString>;
64 print_out(nyan, "nyan".to_string());