4

Tracking Issue for `std::io::read_to_string` · Issue #80218 · rust-lang/rust · G...

 2 years ago
source link: https://github.com/rust-lang/rust/issues/80218
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Member

camelid commented on Dec 20, 2020

edited

Feature gate: #![feature(io_read_to_string)]

This is a tracking issue for the std::io::read_to_string function.

The equivalent of std::fs::read_to_string, but generalized to all
Read impls.

As the documentation on std::io::read_to_string says, the advantage of
this function is that it means you don't have to create a variable first
and it provides more type safety since you can only get the buffer out
if there were no errors. If you use Read::read_to_string, you have to
remember to check whether the read succeeded because otherwise your
buffer will be empty.

It's friendlier to newcomers and better in most cases to use an explicit
return value instead of an out parameter.

Public API

pub fn read_to_string<R: Read>(reader: R) -> Result<String>;

Steps / History

Unresolved Questions

RalfJung, phil-opp, folksgl, DesmondWillowbrook, vi, mehmetcansahin, boringcactus, russellw, andreasfelix, fee1-dead, and 3 more reacted with thumbs up emojiruniq reacted with heart emojiasg0451 reacted with rocket emoji All reactions

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK