Consumed param that can be owned or a ref

If you're always going to call into to produce a String, it's perfectly reasonable in my opinion. That is to say, it offers some ergonomics to consumers without introducing a cost, such as an unnecessary clone.[1]

fn foo<S: Into<String>>(v: S) -> String { ... }

means the same thing but allows turbo-fishing, if you want to be maximally accommodating to consumers.


  1. Potential extra monomorphizing is considered a downside in some niche areas, but that doesn't seem to be your concern. ↩︎

5 Likes