Open ChayimFriedman2 opened 3 years ago
fn name(mut self, name: &str) -> Self { self.name = name.to_string(); self }
It's preferred to take String:
String
fn name(mut self, name: String) -> Self { self.name = name; self }
This way, if the caller already has a String it doesn't perform an unnecessary allocation.
It's preferred to take
String
:This way, if the caller already has a
String
it doesn't perform an unnecessary allocation.