@@ -22,8 +22,8 @@ pub(super) fn expand_manifest(
22
22
gctx : & GlobalContext ,
23
23
) -> CargoResult < String > {
24
24
let source = ScriptSource :: parse ( content) ?;
25
- if let Some ( frontmatter) = source. frontmatter {
26
- match source. info {
25
+ if let Some ( frontmatter) = source. frontmatter ( ) {
26
+ match source. info ( ) {
27
27
Some ( "cargo" ) | None => { }
28
28
Some ( other) => {
29
29
if let Some ( remainder) = other. strip_prefix ( "cargo," ) {
@@ -50,15 +50,15 @@ pub(super) fn expand_manifest(
50
50
)
51
51
. into_path_unlocked ( ) ;
52
52
let mut hacked_source = String :: new ( ) ;
53
- if let Some ( shebang) = source. shebang {
53
+ if let Some ( shebang) = source. shebang ( ) {
54
54
writeln ! ( hacked_source, "{shebang}" ) ?;
55
55
}
56
56
writeln ! ( hacked_source) ?; // open
57
57
for _ in 0 ..frontmatter. lines ( ) . count ( ) {
58
58
writeln ! ( hacked_source) ?;
59
59
}
60
60
writeln ! ( hacked_source) ?; // close
61
- writeln ! ( hacked_source, "{}" , source. content) ?;
61
+ writeln ! ( hacked_source, "{}" , source. content( ) ) ?;
62
62
if let Some ( parent) = hacked_path. parent ( ) {
63
63
cargo_util:: paths:: create_dir_all ( parent) ?;
64
64
}
@@ -279,6 +279,22 @@ impl<'s> ScriptSource<'s> {
279
279
280
280
Ok ( source)
281
281
}
282
+
283
+ fn shebang ( & self ) -> Option < & ' s str > {
284
+ self . shebang
285
+ }
286
+
287
+ fn info ( & self ) -> Option < & ' s str > {
288
+ self . info
289
+ }
290
+
291
+ fn frontmatter ( & self ) -> Option < & ' s str > {
292
+ self . frontmatter
293
+ }
294
+
295
+ fn content ( & self ) -> & ' s str {
296
+ self . content
297
+ }
282
298
}
283
299
284
300
#[ cfg( test) ]
@@ -299,10 +315,10 @@ mod test_expand {
299
315
} ;
300
316
301
317
let mut rendered = String :: new ( ) ;
302
- write_optional_field ( & mut rendered, "shebang" , actual. shebang ) ;
303
- write_optional_field ( & mut rendered, "info" , actual. info ) ;
304
- write_optional_field ( & mut rendered, "frontmatter" , actual. frontmatter ) ;
305
- writeln ! ( & mut rendered, "content: {:?}" , actual. content) . unwrap ( ) ;
318
+ write_optional_field ( & mut rendered, "shebang" , actual. shebang ( ) ) ;
319
+ write_optional_field ( & mut rendered, "info" , actual. info ( ) ) ;
320
+ write_optional_field ( & mut rendered, "frontmatter" , actual. frontmatter ( ) ) ;
321
+ writeln ! ( & mut rendered, "content: {:?}" , actual. content( ) ) . unwrap ( ) ;
306
322
assert_data_eq ! ( rendered, expected. raw( ) ) ;
307
323
}
308
324
0 commit comments