News for hackers. Stuff that matters.
Re:Tour of Rust by Misdicorl on Sunday July 12, 2020 @01:30PM (#23813043)
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

Re:Tour of Rust by zozbot234 on Sunday July 12, 2020 @01:50PM (#23813194)
Returning 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.