Your code is a bit inefficient. I took the liberty of fixing that for you: https://gist.github.com/lhecker/8e89d998c156f0bfdd2d
(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).