@@ -166,15 +166,8 @@ pub(super) mod _impl {
166
166
167
167
/// Symmetrical context before and after the changed hunk.
168
168
ctx_size : u32 ,
169
- // TODO:
170
- // Is there a way to remove `newline` from `UnifiedDiffSink` as it is purely
171
- // formatting-related?
172
- // One option would be to introduce `HunkHeader` with a method `format_header` that could
173
- // then be called outside `UnifiedDiffSink`, potentially taking `newline` as an argument.
174
- newline : NewlineSeparator < ' a > ,
175
169
176
170
buffer : Vec < ( DiffLineType , Vec < u8 > ) > ,
177
- header_buf : String ,
178
171
delegate : D ,
179
172
180
173
err : Option < std:: io:: Error > ,
@@ -191,12 +184,7 @@ pub(super) mod _impl {
191
184
/// to the sink.
192
185
///
193
186
/// The sink's `consume_hunk` method is called for each hunk with structured type information.
194
- pub fn new (
195
- input : & ' a InternedInput < T > ,
196
- consume_hunk : D ,
197
- newline_separator : NewlineSeparator < ' a > ,
198
- context_size : ContextSize ,
199
- ) -> Self {
187
+ pub fn new ( input : & ' a InternedInput < T > , consume_hunk : D , context_size : ContextSize ) -> Self {
200
188
Self {
201
189
interner : & input. interner ,
202
190
before : & input. before ,
@@ -209,10 +197,8 @@ pub(super) mod _impl {
209
197
ctx_pos : None ,
210
198
211
199
ctx_size : context_size. symmetrical ,
212
- newline : newline_separator,
213
200
214
201
buffer : Vec :: with_capacity ( 8 ) ,
215
- header_buf : String :: new ( ) ,
216
202
delegate : consume_hunk,
217
203
218
204
err : None ,
@@ -237,23 +223,6 @@ pub(super) mod _impl {
237
223
238
224
let hunk_start = self . before_hunk_start + 1 ;
239
225
let hunk_end = self . after_hunk_start + 1 ;
240
- self . header_buf . clear ( ) ;
241
- std:: fmt:: Write :: write_fmt (
242
- & mut self . header_buf ,
243
- format_args ! (
244
- "@@ -{},{} +{},{} @@{nl}" ,
245
- hunk_start,
246
- self . before_hunk_len,
247
- hunk_end,
248
- self . after_hunk_len,
249
- nl = match self . newline {
250
- NewlineSeparator :: AfterHeaderAndLine ( nl) | NewlineSeparator :: AfterHeaderAndWhenNeeded ( nl) => {
251
- nl
252
- }
253
- }
254
- ) ,
255
- )
256
- . map_err ( |err| std:: io:: Error :: new ( ErrorKind :: Other , err) ) ?;
257
226
258
227
// TODO:
259
228
// Is this explicit conversion necessary?
@@ -394,7 +363,7 @@ pub(super) mod _impl {
394
363
} ;
395
364
// TODO:
396
365
// Should this return a `UnifiedDiff` instead of a `UnifiedDiffSink`?
397
- UnifiedDiffSink :: new ( input, formatter, newline_separator , context_size)
366
+ UnifiedDiffSink :: new ( input, formatter, context_size)
398
367
}
399
368
400
369
fn format_line ( & mut self , line_type : DiffLineType , content : & [ u8 ] ) {
0 commit comments