Make std.string.removechars @safe and pure

In `removechars`, `r` is newly allocated array. So it can be safe to cast it to the string type.
I use a trusted nested function instead of trusted lambda call because of the performance issue.