(self, rhs: i32)
| 42 | type Output = MyString; |
| 43 | |
| 44 | fn mul(self, rhs: i32) -> Self::Output { |
| 45 | println!("> MyString.mul({}) was called", &rhs); |
| 46 | let caplen: usize = if rhs <= 0 { 0 } else { rhs as usize }; |
| 47 | let mut temp = String::with_capacity(&self.0.len() * caplen); |
| 48 | for _ in 0..rhs { |
| 49 | temp.write_str(&self.0).expect("writing to string failed"); |
| 50 | } |
| 51 | MyString(temp) |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | fn main() { |