by lhecker · 10y ago · 0 comments
(You can use that code freely and without any attribution if you want to.)
The important part here is to use `String::with_capacity()` to prevent unnecessary reallocations. Furthermore I used `usize::saturating_sub()` because it's neat and cleaned up the code with `rustfmt` (which you should use).
https://github.com/hfiguiere/leftpad-rs/pull/2
Sadly it has gathered some rust (pun intended !)