rust-fsharp
rust-fsharp copied to clipboard
Taking a `&str` when you need `String` is considered unidiomatic
fn name(mut self, name: &str) -> Self { self.name = name.to_string(); self }
It's preferred to take 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.