As an optimization for the case when the slice length is not less than the padded size, the original slice could be returned in a Cow::Borrowed.
Changing the return type would be a breaking change, so if you have an established base of developers depending on your crate with leftpad = "*" and you don't want to upset them, a couple of functions could be added alongside:
As an optimization for the case when the slice length is not less than the padded size, the original slice could be returned in a
Cow::Borrowed
.Changing the return type would be a breaking change, so if you have an established base of developers depending on your crate with
leftpad = "*"
and you don't want to upset them, a couple of functions could be added alongside:left_pad_to_cow
left_pad_char_to_cow