Use str.char_offset_iter instead of manually calling str.char_range_at.

And 3 other minor clean-ups: removing a redundant `if`, a redundant function call, and using `slice_from` where it is possible.