# Pastebin q7xQGbeY fun ref rstrip(s: String box = " \t\v\f\r\n") => """ Remove all trailing characters within the string that are in s. By default, trailing whitespace is removed. """ if _size > 0 then let chars = Array[U32](s.size()) var i = _size - 1 var truncate_at = i for rune in s.runes() do chars.push(rune) end repeat try match utf32(i.isize())? | (0xFFFD, 1) => None | (let c: U32, _) => if not chars.contains(c) then break end truncate_at = i end else break end until (i = i - 1) == 0 end truncate(truncate_at) end