@@ -68,12 +68,15 @@ pub enum NewlineSeparator<'a> {
68
68
AfterHeaderAndWhenNeeded ( & ' a str ) ,
69
69
}
70
70
71
- /// TODO:
72
- /// Document.
71
+ /// Holds information about a unified diff hunk, specifically with respect to line numbers.
73
72
pub struct HunkHeader {
73
+ /// The 1-based start position in the 'before' lines.
74
74
before_hunk_start : u32 ,
75
+ /// The size of the 'before' hunk in lines.
75
76
before_hunk_len : u32 ,
77
+ /// The 1-based start position in the 'after' lines.
76
78
after_hunk_start : u32 ,
79
+ /// The size of the 'after' hunk in lines.
77
80
after_hunk_len : u32 ,
78
81
}
79
82
@@ -89,15 +92,14 @@ impl std::fmt::Display for HunkHeader {
89
92
90
93
/// A utility trait for use in [`UnifiedDiffSink`](super::UnifiedDiffSink).
91
94
pub trait ConsumeTypedHunk {
92
- /// TODO:
93
- /// Document.
95
+ /// The item this instance produces after consuming all hunks.
94
96
type Out ;
95
97
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 .
101
103
fn consume_hunk ( & mut self , header : HunkHeader , lines : & [ ( DiffLineType , & [ u8 ] ) ] ) -> std:: io:: Result < ( ) > ;
102
104
103
105
/// Called when processing is complete.
@@ -224,10 +226,6 @@ pub(super) mod _impl {
224
226
let hunk_start = self . before_hunk_start + 1 ;
225
227
let hunk_end = self . after_hunk_start + 1 ;
226
228
227
- // TODO:
228
- // Is this explicit conversion necessary?
229
- // Is the comment necessary?
230
- // Convert Vec<(DiffLineType, Vec<u8>)> to Vec<(DiffLineType, &[u8])>
231
229
let lines: Vec < ( DiffLineType , & [ u8 ] ) > = self
232
230
. buffer
233
231
. iter ( )
@@ -458,8 +456,6 @@ pub(super) mod _impl {
458
456
459
457
for & ( line_type, content) in lines {
460
458
self . push ( line_type. to_prefix ( ) ) ;
461
- // TODO:
462
- // How does `impl ConsumeHunk for String` handle errors?
463
459
self . push_str ( std:: str:: from_utf8 ( content) . map_err ( |e| std:: io:: Error :: new ( ErrorKind :: Other , e) ) ?) ;
464
460
self . push ( '\n' ) ;
465
461
}
0 commit comments