on master help sign in
add missing doc
6564257Shafkath Shuhan
helix-view/src/document.rs+8
@@ -179,6 +179,10 @@ pub fn from_reader<R: std::io::Read + ?Sized>(
179 loop {
179 loop {
180 let mut total_read = 0usize;
180 let mut total_read = 0usize;
181
181
182+ // An inner loop is necessary as it is possible that the input buffer
183+ // may not be completely decoded on the first `decode_to_str()` call
184+ // which would happen in cases where the output buffer is filled to
185+ // capacity.
182 loop {
186 loop {
183 let (result, read, written, ..) = decoder.decode_to_str(
187 let (result, read, written, ..) = decoder.decode_to_str(
184 &slice[total_read..],
188 &slice[total_read..],
@@ -252,6 +256,10 @@ pub async fn to_writer<'a, W: tokio::io::AsyncWriteExt + Unpin + ?Sized>(
252 let is_empty = chunk.is_empty();
256 let is_empty = chunk.is_empty();
253 let mut total_read = 0usize;
257 let mut total_read = 0usize;
254
258
259+ // An inner loop is necessary as it is possible that the input buffer
260+ // may not be completely encoded on the first `encode_from_utf8()` call
261+ // which would happen in cases where the output buffer is filled to
262+ // capacity.
255 loop {
263 loop {
256 let (result, read, written, ..) =
264 let (result, read, written, ..) =
257 encoder.encode_from_utf8(&chunk[total_read..], &mut buf[total_written..], is_empty);
265 encoder.encode_from_utf8(&chunk[total_read..], &mut buf[total_written..], is_empty);