Add new function str.truncate()
auto merge of #8732 : kballard/rust/str-truncate, r=thestinger