MCPcopy Create free account
hub / github.com/bedroombuilds/python2rust / mul

Method mul

0c_operator_overloading/rust/operator_overloading.rs:44–52  ·  view source on GitHub ↗
(self, rhs: i32)

Source from the content-addressed store, hash-verified

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
55fn main() {

Callers

nothing calls this directly

Calls 1

MyStringClass · 0.85

Tested by

no test coverage detected