String::borrow
vs String::as_str
both would give &str
. I would like to use borrow()
for possibility to later refactor structures to Cow<str>
, but would that incur any extra costs due to .borrow()
being a trait method?
I guess compiler might optimise that as it is a trait on a predefined type.
Thank you