3 ms·
Making it return a string would be a mistake for the space rust wants to (first) play in: low level system development. Returning a String requires figuring out
by Misdicorl 6y ago
Making it return a string would be a mistake for the space rust wants to (first) play in: low level system development. Returning a String requires figuring out what encoding the string has and parsing the contents in that encoding. That's not trivial or cheap or sometimes even possible (not all byte combinations are valid in all encodings) compared to filling a vec of bytes.
That said, it's probably worthwhile to expose the functionality since people would find it useful in a lot of cases
- zozbot234 6y agoReturning a String is not necessarily a mistake; you could check for UTF-8 validity and error out if the line is not valid UTF-8 - and if you're providing a wrapper for "simple" uses, this might even be the right call. You're right that the general case involves outputing raw bytes, of course.