Skip to content

Commit

Permalink
add missing doc
Browse files Browse the repository at this point in the history
  • Loading branch information
kirawi committed Jun 23, 2021
1 parent b701215 commit 7cc7cf8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions helix-view/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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..],
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7cc7cf8

Please sign in to comment.