@@ -68,12 +68,15 @@ pub enum NewlineSeparator<'a> {
6868 AfterHeaderAndWhenNeeded ( & ' a str ) ,
6969}
7070
71- /// TODO:
72- /// Document.
71+ /// Holds information about a unified diff hunk, specifically with respect to line numbers.
7372pub struct HunkHeader {
73+ /// The 1-based start position in the 'before' lines.
7474 before_hunk_start : u32 ,
75+ /// The size of the 'before' hunk in lines.
7576 before_hunk_len : u32 ,
77+ /// The 1-based start position in the 'after' lines.
7678 after_hunk_start : u32 ,
79+ /// The size of the 'after' hunk in lines.
7780 after_hunk_len : u32 ,
7881}
7982
@@ -89,15 +92,14 @@ impl std::fmt::Display for HunkHeader {
8992
9093/// A utility trait for use in [`UnifiedDiffSink`](super::UnifiedDiffSink).
9194pub trait ConsumeTypedHunk {
92- /// TODO:
93- /// Document.
95+ /// The item this instance produces after consuming all hunks.
9496 type Out ;
9597
96- /// TODO:
97- /// Document.
98- /// How do we want to pass the header to `consume_hunk`? We can add an additional parameter
99- /// similar to `ConsumeHunk::consume_hunk` or add `DiffLineType::Header` in which case we
100- /// didn’t have to add an additional parameter .
98+ /// Consume a single hunk.
99+ ///
100+ /// Note that the [`UnifiedDiffSink`](super::UnifiedDiffSink) sink will wrap its output in a
101+ /// [`std::io::Result`]. After this method returned its first error, it will not be called
102+ /// again .
101103 fn consume_hunk ( & mut self , header : HunkHeader , lines : & [ ( DiffLineType , & [ u8 ] ) ] ) -> std:: io:: Result < ( ) > ;
102104
103105 /// Called when processing is complete.
@@ -224,10 +226,6 @@ pub(super) mod _impl {
224226 let hunk_start = self . before_hunk_start + 1 ;
225227 let hunk_end = self . after_hunk_start + 1 ;
226228
227- // TODO:
228- // Is this explicit conversion necessary?
229- // Is the comment necessary?
230- // Convert Vec<(DiffLineType, Vec<u8>)> to Vec<(DiffLineType, &[u8])>
231229 let lines: Vec < ( DiffLineType , & [ u8 ] ) > = self
232230 . buffer
233231 . iter ( )
@@ -458,8 +456,6 @@ pub(super) mod _impl {
458456
459457 for & ( line_type, content) in lines {
460458 self . push ( line_type. to_prefix ( ) ) ;
461- // TODO:
462- // How does `impl ConsumeHunk for String` handle errors?
463459 self . push_str ( std:: str:: from_utf8 ( content) . map_err ( |e| std:: io:: Error :: new ( ErrorKind :: Other , e) ) ?) ;
464460 self . push ( '\n' ) ;
465461 }
0 commit comments