Add support for trimming strings
We should add a set of methods used for trimming strings. The most common case is whitespace (all whitespace, not just spaces), followed by arbitrary characters. Trimming should support trimming both the start and end at the same time, just the start, and just the end of a string.
Rust takes the following approach: trimming whitspace is done using methods such
as String::trim
and String::trim_start
, while trimming arbitrary characters
is done using String::strip_prefix
and String::strip_suffix
. Rust also has
String::trim_matches
, but I'm not sure this would work in Inko as we'd have to
allocate a String
for every character, which I prefer to avoid.
My current thinking is to introduce these methods:
Method | Purpose |
---|---|
String.trim |
Remove trailing and leading whitespace |
String.trim_start |
Remove leading whitespace |
String.trim_end |
Remove trailing whitespace |
String.strip(x) |
Remove the string x from the start and end |
String.strip_start(x) |
Remove the string x from the start |
String.strip_end(x) |
Remove the string x from the end |