@@ -216,10 +216,12 @@ fn split_source(input: &str) -> CargoResult<Source<'_>> {
216
216
}
217
217
218
218
// No other choice than to consider this a shebang.
219
- let ( shebang , content ) = source
219
+ let newline_end = source
220
220
. content
221
- . split_once ( '\n' )
222
- . unwrap_or ( ( source. content , "" ) ) ;
221
+ . find ( '\n' )
222
+ . map ( |pos| pos + 1 )
223
+ . unwrap_or ( source. content . len ( ) ) ;
224
+ let ( shebang, content) = source. content . split_at ( newline_end) ;
223
225
source. shebang = Some ( shebang) ;
224
226
source. content = content;
225
227
}
@@ -401,7 +403,7 @@ fn main() {}
401
403
Ok(
402
404
Source {
403
405
shebang: Some(
404
- "#!/usr/bin/env cargo",
406
+ "#!/usr/bin/env cargo\n ",
405
407
),
406
408
info: None,
407
409
frontmatter: Some(
427
429
Ok(
428
430
Source {
429
431
shebang: Some(
430
- "#!/usr/bin/env cargo\r",
432
+ "#!/usr/bin/env cargo\r\n ",
431
433
),
432
434
info: Some(
433
435
"",
@@ -466,7 +468,7 @@ fn main() {}
466
468
Ok(
467
469
Source {
468
470
shebang: Some(
469
- "#!/usr/bin/env cargo",
471
+ "#!/usr/bin/env cargo\n ",
470
472
),
471
473
info: None,
472
474
frontmatter: None,
@@ -524,7 +526,7 @@ fn main() {}"#
524
526
Ok(
525
527
Source {
526
528
shebang: Some(
527
- "#!/usr/bin/env cargo",
529
+ "#!/usr/bin/env cargo\n ",
528
530
),
529
531
info: None,
530
532
frontmatter: Some(
0 commit comments