Feel somewhat confused that `io::Read::read_to_string` writes into a referenced string, while `fs::read_to_string` allocates a new string. Could imagine the justification for it is method vs function, but it's... somewhat nuanced?
-
-
I think it is since Read is a generic trait. It could be a file it could be a network socket. In both cases they abstract over this, it's just the use of fs that makes it clear it's reading from a file. Idk how else you'd name them
-
Not sure I follow? I'm referring to the relationship between the function and String. E.g. read_to_string(s: &mut String) -> Result<()> vs read_to_string() -> Result<String> One uses a reference, the other allocates.
- 4 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
