File tree 1 file changed +13
-0
lines changed
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -953,6 +953,19 @@ pub trait Read {
953
953
/// use [`Read::read_to_string`] you have to remember to check whether the read
954
954
/// succeeded because otherwise your buffer will be empty or only partially full.)
955
955
///
956
+ /// # Performance
957
+ ///
958
+ /// The downside of this function's increased ease of use and type safety is
959
+ /// that it gives you less control over performance. For example, you can't
960
+ /// pre-allocate memory like you can using [`String::with_capacity`] and
961
+ /// [`Read::read_to_string`]. Also, you can't re-use the buffer if an error
962
+ /// occurs while reading.
963
+ ///
964
+ /// In many cases, this function's performance will be adequate and the ease of use
965
+ /// and type safety tradeoffs will be worth it. However, there are cases where you
966
+ /// need more control over performance, and in those cases you should definitely use
967
+ /// [`Read::read_to_string`] directly.
968
+ ///
956
969
/// # Errors
957
970
///
958
971
/// This function forces you to handle errors because the output (the `String`)
You can’t perform that action at this time.
0 commit comments