I am trying to parse the output of a
Command::new("cmd").output()?.stdout, splitting it into lines of whitespace-separated fields. (Definition of whitespace similar to the C locale: tab, space, \n) Basically a Vec (lines) of Vec (fields) of OsStr (or any other practical type) slices that point to the initial buffer.
I would like to avoid converting back and from Strings, since I can't be sure about the encoding of the data, and it's just data that I will most likely feed into other operating system utilities. So I decided that the best type is
OsStr, but I am open to other possibilities.
How can I do this best? I have had quite a few hurdles on my way:
- working with
OsStrs is a pain since they don't provide all String utilities (like split_whitespace()).
- what is the idiomatic way to write this cross-platform? ATM I convert
OsStr::from_bytes()but this apparently only works on UNIX.
Thank you in advance.