Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: Remove an implicit panic from Formatter::pad
The expression `&s[..i]` in general can panic if `i` is out of bounds or not on a character boundary for a string, and this caused the codegen for `Formatter::pad` to be a bit larger than it otherwise needed to be. This commit replaces this with `s.get(..i).unwrap_or(&s)` which while having different behavior if `i` is out of bounds has a much smaller code footprint and otherwise avoids the need for `unsafe` code.
- Loading branch information