diff options
author | Shafkath Shuhan | 2021-06-23 06:13:45 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-06-23 06:40:27 +0000 |
commit | 6564257a7b55259314095afa132fb6fdbcf3e6eb (patch) | |
tree | f2262cd1e9d49a402cdb888af5e9ebcf6ba7c02f /helix-view | |
parent | 7896eefd733c19a82cac0e4a6cfc7fd4ec0a9643 (diff) |
add missing doc
Diffstat (limited to 'helix-view')
-rw-r--r-- | helix-view/src/document.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 92778ad7..dc004336 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -179,6 +179,10 @@ pub fn from_reader<R: std::io::Read + ?Sized>( loop { let mut total_read = 0usize; + // An inner loop is necessary as it is possible that the input buffer + // may not be completely decoded on the first `decode_to_str()` call + // which would happen in cases where the output buffer is filled to + // capacity. loop { let (result, read, written, ..) = decoder.decode_to_str( &slice[total_read..], @@ -252,6 +256,10 @@ pub async fn to_writer<'a, W: tokio::io::AsyncWriteExt + Unpin + ?Sized>( let is_empty = chunk.is_empty(); let mut total_read = 0usize; + // An inner loop is necessary as it is possible that the input buffer + // may not be completely encoded on the first `encode_from_utf8()` call + // which would happen in cases where the output buffer is filled to + // capacity. loop { let (result, read, written, ..) = encoder.encode_from_utf8(&chunk[total_read..], &mut buf[total_written..], is_empty); |